Module: Configuration
- Included in:
- Birdsong
- Defined in:
- lib/helpers/configuration.rb
Overview
Borrowed with thanks from www.viget.com/articles/easy-gem-configuration-variables-with-defaults/
Instance Method Summary collapse
Instance Method Details
#configuration {|_self| ... } ⇒ Object
5 6 7 |
# File 'lib/helpers/configuration.rb', line 5 def configuration yield self end |
#define_setting(name, default = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/helpers/configuration.rb', line 9 def define_setting(name, default = nil) class_variable_set("@@#{name}", default) define_class_method "#{name}=" do |value| class_variable_set("@@#{name}", value) end define_class_method name do class_variable_get("@@#{name}") end end |