Sha256: 089a7c53c3c0d472847ca24b9cb0eba8a558c59c2dce4ae2f27cadd075bbbbd0

Contents?: true

Size: 811 Bytes

Versions: 19

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Tramway::Core::ApplicationForms::SubmitHelper
  def submit(params)
    if params
      params.each { |key, value| send("#{key}=", value) }
      result = save
      result.tap do
        collecting_associations_errors unless result
      end
    else
      Tramway::Error.raise_error(:tramway, :core, :application_form, :submit, :params_should_not_be_nil)
    end
  end

  def save
    model.save
  rescue ArgumentError => e
    Tramway::Error.raise_error :tramway, :core, :application_form, :save, :argument_error, message: e.message
  rescue StandardError => e
    Tramway::Error.raise_error :tramway, :core, :application_form, :save, :looks_like_you_have_method,
      method_name: e.name.to_s.gsub('=', ''), model_class: @@model_class, class_name: self.class
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
tramway-core-1.18.6 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.5.2 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.5.1 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.5 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.4 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3.5 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3.4 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3.3 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3.2 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3.1 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.3 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.2 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.1.2 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.1.1 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.1 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.0.4 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.0.3 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.0.2 app/forms/tramway/core/application_forms/submit_helper.rb
tramway-core-1.18.0.1 app/forms/tramway/core/application_forms/submit_helper.rb