Sha256: de08e0245bbd5cfdb696e479bdae38387fdf2a332624919ae0045236ee14be4e

Contents?: true

Size: 623 Bytes

Versions: 21

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

module Tramway::Core::ExtendableFormsHelpers::Submit::ClassHelpers
  def define_submit_method(simple_properties, more_properties)
    define_method 'submit' do |params|
      model.values ||= {}
      extended_params = extended(simple_properties, more_properties, params)
      params.each do |key, value|
        method_name = "#{key}="
        send method_name, value if respond_to?(method_name)
      end
      model.values = extended_params.reduce(model.values) do |hash, pair|
        hash.merge! pair[0] => pair[1]
      end
      super(params) && model.errors.empty?
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
tramway-core-1.18.0.2 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.18.0.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.18 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.9.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.9 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.8 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.7.2 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.7.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.7 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.6.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.6 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.5 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.4.2 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.4.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.4 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.3.1 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.3 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.2.5 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.2.4 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
tramway-core-1.17.2.3 app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb