Module: Parametric::Params::DSL
- Defined in:
- lib/parametric/params.rb
Instance Method Summary collapse
-
#inherited(subclass) ⇒ Object
When subclasses params definitions we want to copy parent class definitions so changes in the child class don’t mutate the parent definitions.
- #param(field_name, label = '', opts = {}, &block) ⇒ Object
Instance Method Details
#inherited(subclass) ⇒ Object
When subclasses params definitions we want to copy parent class definitions so changes in the child class don’t mutate the parent definitions
69 70 71 |
# File 'lib/parametric/params.rb', line 69 def inherited(subclass) subclass._allowed_params = self._allowed_params.dup end |
#param(field_name, label = '', opts = {}, &block) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/parametric/params.rb', line 73 def param(field_name, label = '', opts = {}, &block) opts[:label] = label if block_given? nested = Class.new(Parametric::Hash) nested.instance_eval &block opts[:nested] = nested end _allowed_params[field_name] = opts end |