-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.irbrc
59 lines (50 loc) · 1.15 KB
/
.irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = '~/.irb-history'
def ras
require "active_support/all"
end
def uuid
require "securerandom"
SecureRandom.uuid
end
def set_account(id)
Account.find(id).set_schema_search_path
end
def load(condition = :always, &block)
begin
case condition
when :always
block.call
when :rails
block.call if ENV['RAILS_ENV']
when :irb
block.call unless ENV['RAILS_ENV']
end
rescue Exception => ex
puts ex
end
end
load(:irb) do
require 'whats_up/classic'
# Fix whats_up for rails console
blacklist = WhatsUp::MethodFinder.class_variable_get("@@blacklist")
blacklist += Object.instance_methods
WhatsUp::MethodFinder.class_variable_set("@@blacklist", blacklist)
end
load(:rails) do
begin
# Including FactoryBot breaks the following command:
# WorkOrder.first.update(description: "lkj")
#include FactoryBot::Syntax::Methods
rescue Exception => ex
puts ex
end
end
load do
require 'interactive_editor'
end
load do
# Predefine hash and array instances for convenience
H = { bob: 'Bob', mom: 'Mom', gods: 'Gos', chris: 'Chris' }
A = H.keys
end