Module: Trestle::Configurable::ClassMethods
- Defined in:
- lib/trestle/configurable.rb
Instance Method Summary collapse
Instance Method Details
#defaults ⇒ Object
42 43 44 |
# File 'lib/trestle/configurable.rb', line 42 def defaults @defaults ||= {} end |
#option(name, default = nil, opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/trestle/configurable.rb', line 46 def option(name, default=nil, opts={}) name = name.to_sym define_method("#{name}=") do |value| assign(name, value) end define_method(name) do |*args| value = fetch(name) if value.respond_to?(:call) && opts[:evaluate] != false value = value.call(*args) end value end defaults[name] = default end |