Permalink
Browse files

Improving conditionals statements

  • Loading branch information...
1 parent 88e1720 commit 5750910d1defabae2af0f6e1e728c40c294578fd @robertomiranda robertomiranda committed Oct 4, 2012
Showing with 6 additions and 18 deletions.
  1. +6 −18 lib/settingslogic.rb
View
@@ -22,27 +22,15 @@ def get(key)
end
def source(value = nil)
- if value.nil?
- @source
- else
- @source = value
- end
+ @source ||= value
end
def namespace(value = nil)
- if value.nil?
- @namespace
- else
- @namespace = value
- end
+ @namespace ||= value
end
def suppress_errors(value = nil)
- if value.nil?
- @suppress_errors
- else
- @suppress_errors = value
- end
+ @suppress_errors ||= value
end
def [](key)
@@ -60,20 +48,20 @@ def load!
instance
true
end
-
+
def reload!
@instance = nil
load!
end
-
+
private
def instance
return @instance if @instance
@instance = new
create_accessors!
@instance
end
-
+
def method_missing(name, *args, &block)
instance.send(name, *args, &block)
end

0 comments on commit 5750910

Please sign in to comment.