Module: Lab42::Config::ClassMethods
- Defined in:
- lib/lab42/config/class_methods.rb
Instance Method Summary collapse
Instance Method Details
#__config__ ⇒ Object
9 10 11 |
# File 'lib/lab42/config/class_methods.rb', line 9 def __config__ @__config__ ||= Lab42::Config::ClassLevelConfig.new end |
#config(&blk) ⇒ Object
6 7 8 |
# File 'lib/lab42/config/class_methods.rb', line 6 def config &blk __config__.instance_exec &blk end |
#instance_config(*names) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lab42/config/class_methods.rb', line 13 def instance_config *names names.each do | name | ivar_name = "@__lab42_config_local__#{name}__" # define getter define_method name do instance_variable_defined?( ivar_name ) ? instance_variable_get( ivar_name ) : instance_variable_set( ivar_name, configuration.__send__( name ) ) end # define setter define_method "#{name}=" do |val| instance_variable_set( ivar_name, val ) end end end |