Skip to content

Loading…

Improving conditional statements #37

Merged
merged 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @robertomiranda

    ignore .rvmrc

    robertomiranda committed
  2. @robertomiranda
Showing with 7 additions and 18 deletions.
  1. +1 −0 .gitignore
  2. +6 −18 lib/settingslogic.rb
View
1 .gitignore
@@ -7,3 +7,4 @@ doc/*
benchmarks/*
.bundle
vendor/bundle
+.rvmrc
View
24 lib/settingslogic.rb
@@ -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,12 +48,12 @@ def load!
instance
true
end
-
+
def reload!
@instance = nil
load!
end
-
+
private
def instance
return @instance if @instance
@@ -73,7 +61,7 @@ def instance
create_accessors!
@instance
end
-
+
def method_missing(name, *args, &block)
instance.send(name, *args, &block)
end
Something went wrong with that request. Please try again.