Module: Trestle::Configurable::ClassMethods
- Defined in:
- lib/trestle/configurable.rb
Instance Method Summary collapse
- #defaults ⇒ Object
- #deprecated_option(name, message = nil) ⇒ Object
- #option(name, default = nil, opts = {}) ⇒ Object
Instance Method Details
#defaults ⇒ Object
48 49 50 |
# File 'lib/trestle/configurable.rb', line 48 def defaults @defaults ||= {} end |
#deprecated_option(name, message = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/trestle/configurable.rb', line 72 def deprecated_option(name, =nil) define_method("#{name}=") do |value| Trestle.deprecator.warn() end define_method(name) do |*args| Trestle.deprecator.warn() end end |
#option(name, default = nil, opts = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/trestle/configurable.rb', line 52 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 |