Module: Trenchcoat::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/trenchcoat.rb

Overview

The concern to include in your ActiveModel class definition

Instance Method Summary collapse

Instance Method Details

#fallback_to_model_values(model:, attributes_to_check:, original_attributes_hash:) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/trenchcoat.rb', line 11

def fallback_to_model_values(model:, attributes_to_check:, original_attributes_hash:)
  indifferent_original_attributes = original_attributes_hash.to_h.with_indifferent_access
  attributes_to_check.each do |attribute|
    next if indifferent_original_attributes.key?(attribute)

    send(:"#{attribute}=", model.public_send(attribute))
  end
end