Module: StrictLoading::Core::ClassMethods

Defined in:
lib/strict-loading/core.rb

Instance Method Summary collapse

Instance Method Details

#strict_loading_violation!(owner:, reflection:) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/strict-loading/core.rb', line 31

def strict_loading_violation!(owner:, reflection:)
  case ActiveRecord::Base.action_on_strict_loading_violation
  when :raise
    message = reflection.strict_loading_violation_message(owner)
    raise ActiveRecord::StrictLoadingViolationError.new(message)
  when :log
    name = "strict_loading_violation.active_record"
    ActiveSupport::Notifications.instrument(name, owner: owner, reflection: reflection)
  end
end