Sha256: 71d1e96c5135482589c151059ea64800fd3fae4bf944a52878ebe1c73347ed34

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 Bytes

Contents

# frozen_string_literal: true

module Tramway::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)
      every_attribute_set params
      model.values = extended_params.reduce(model.values) do |hash, (key, value)|
        hash.merge! key => value
      end

      return unless model.errors.empty?

      save_in_submit params
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tramway-0.1.2 app/forms/tramway/extendable_forms_helpers/submit/class_helpers.rb
tramway-0.1.1.1 app/forms/tramway/extendable_forms_helpers/submit/class_helpers.rb
tramway-0.1.1 app/forms/tramway/extendable_forms_helpers/submit/class_helpers.rb