Module: Retter::Configurable
Instance Method Summary collapse
- #configurable(*names) ⇒ Object
- #define_configurable_method(name) ⇒ Object
- #define_instance_shortcut_method(name) ⇒ Object
Instance Method Details
#configurable(*names) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/retter/configurable.rb', line 5 def configurable(*names) names.each do |name| define_configurable_method name define_instance_shortcut_method name end end |
#define_configurable_method(name) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/retter/configurable.rb', line 12 def define_configurable_method(name) instance_eval <<-EOM def #{name}(val = nil) val ? @#{name} = val : @#{name} end EOM end |
#define_instance_shortcut_method(name) ⇒ Object
20 21 22 23 24 |
# File 'lib/retter/configurable.rb', line 20 def define_instance_shortcut_method(name) define_method name do self.class.send(name) end end |