Commit 5750910d1defabae2af0f6e1e728c40c294578fd
1 parent
88e17200
Exists in
master
Improving conditionals statements
Showing
1 changed file
with
6 additions
and
18 deletions
Show diff stats
lib/settingslogic.rb
... | ... | @@ -22,27 +22,15 @@ class Settingslogic < Hash |
22 | 22 | end |
23 | 23 | |
24 | 24 | def source(value = nil) |
25 | - if value.nil? | |
26 | - @source | |
27 | - else | |
28 | - @source = value | |
29 | - end | |
25 | + @source ||= value | |
30 | 26 | end |
31 | 27 | |
32 | 28 | def namespace(value = nil) |
33 | - if value.nil? | |
34 | - @namespace | |
35 | - else | |
36 | - @namespace = value | |
37 | - end | |
29 | + @namespace ||= value | |
38 | 30 | end |
39 | 31 | |
40 | 32 | def suppress_errors(value = nil) |
41 | - if value.nil? | |
42 | - @suppress_errors | |
43 | - else | |
44 | - @suppress_errors = value | |
45 | - end | |
33 | + @suppress_errors ||= value | |
46 | 34 | end |
47 | 35 | |
48 | 36 | def [](key) |
... | ... | @@ -60,12 +48,12 @@ class Settingslogic < Hash |
60 | 48 | instance |
61 | 49 | true |
62 | 50 | end |
63 | - | |
51 | + | |
64 | 52 | def reload! |
65 | 53 | @instance = nil |
66 | 54 | load! |
67 | 55 | end |
68 | - | |
56 | + | |
69 | 57 | private |
70 | 58 | def instance |
71 | 59 | return @instance if @instance |
... | ... | @@ -73,7 +61,7 @@ class Settingslogic < Hash |
73 | 61 | create_accessors! |
74 | 62 | @instance |
75 | 63 | end |
76 | - | |
64 | + | |
77 | 65 | def method_missing(name, *args, &block) |
78 | 66 | instance.send(name, *args, &block) |
79 | 67 | end | ... | ... |