Skip to content

Instantly share code, notes, and snippets.

@juandebravo
Created December 18, 2012 09:58
Show Gist options
  • Save juandebravo/4326766 to your computer and use it in GitHub Desktop.
Save juandebravo/4326766 to your computer and use it in GitHub Desktop.
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