Skip to content

Commit 52722f1

Browse files
committed
Merge pull request #37 from robertomiranda/roberto/improving_code_style
Improving conditional statements
2 parents ea15363 + 5750910 commit 52722f1

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ doc/*
77
benchmarks/*
88
.bundle
99
vendor/bundle
10+
.rvmrc

lib/settingslogic.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,15 @@ def get(key)
2222
end
2323

2424
def source(value = nil)
25-
if value.nil?
26-
@source
27-
else
28-
@source = value
29-
end
25+
@source ||= value
3026
end
3127

3228
def namespace(value = nil)
33-
if value.nil?
34-
@namespace
35-
else
36-
@namespace = value
37-
end
29+
@namespace ||= value
3830
end
3931

4032
def suppress_errors(value = nil)
41-
if value.nil?
42-
@suppress_errors
43-
else
44-
@suppress_errors = value
45-
end
33+
@suppress_errors ||= value
4634
end
4735

4836
def [](key)
@@ -60,20 +48,20 @@ def load!
6048
instance
6149
true
6250
end
63-
51+
6452
def reload!
6553
@instance = nil
6654
load!
6755
end
68-
56+
6957
private
7058
def instance
7159
return @instance if @instance
7260
@instance = new
7361
create_accessors!
7462
@instance
7563
end
76-
64+
7765
def method_missing(name, *args, &block)
7866
instance.send(name, *args, &block)
7967
end

0 commit comments

Comments
 (0)