Created
December 18, 2012 09:58
-
-
Save juandebravo/4326766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
class << self | |
attr_accessor :configuration | |
def config(value=nil) | |
if block_given? | |
yield configuration | |
elsif value | |
configuration[value] | |
else | |
configuration | |
end | |
end | |
private | |
def configuration | |
@configuration ||= {} | |
end | |
end | |
end | |
Foo.config do |c| | |
c[:foo] = 'bar' | |
end | |
puts Foo.config | |
puts Foo.config[:foo] | |
Foo.config[:bar] = 'bazz' | |
puts Foo.config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment