Module: Tramway::Core::ExtendableFormsHelpers::PropertiesHelper

Defined in:
app/forms/tramway/core/extendable_forms_helpers/properties_helper.rb

Instance Method Summary collapse

Instance Method Details

#define_properties_method(simple_properties, more_properties) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/forms/tramway/core/extendable_forms_helpers/properties_helper.rb', line 4

def define_properties_method(simple_properties, more_properties)
  define_method 'properties' do
    hash = simple_properties.each_with_object({}) do |property, h|
      h.merge! property[0] => property[1] unless model.class.state_machines.keys.include?(property[0])
    end
    more_properties.reduce(hash) do |h, property|
      h.merge! property[0] => {
        extended_form_property: property[1][:object]
      }
    end
  end
end