Module: Potter::OptionHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- Field, Types::Type
- Defined in:
- lib/potter/option_helpers.rb
Instance Method Summary collapse
Instance Method Details
#assign_option!(k, default:, block:) ⇒ Object
14 15 16 17 |
# File 'lib/potter/option_helpers.rb', line 14 def assign_option!(k, default:, block:) value = @options.delete(k) { default.respond_to?(:call) ? instance_exec(&default) : default.clone } instance_variable_set("@#{k}", block.(value)) end |
#assign_options! ⇒ Object
9 10 11 12 |
# File 'lib/potter/option_helpers.rb', line 9 def (**) @options ||= {**} self.class..each { assign_option!(_1, **_2) } end |