Exception: Lyra::StrictDataAccessViolation

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lyra/strict_data_access.rb

Overview

Error raised when strict data access mode is enabled and a callback-bypassing operation is attempted on a Lyra-monitored model.

Constant Summary collapse

ALTERNATIVES =
{
  update_columns: "update!",
  update_column: "update!",
  delete: "destroy",
  update_all: "find_each { |r| r.update!(...) }",
  delete_all: "find_each(&:destroy)",
  insert_all: "records.each { |attrs| create!(attrs) }",
  insert_all!: "records.each { |attrs| create!(attrs) }",
  upsert_all: "records.each { |attrs| find_or_create_by!(...).update!(attrs) }"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, model_class) ⇒ StrictDataAccessViolation

Returns a new instance of StrictDataAccessViolation.



20
21
22
23
24
25
26
# File 'lib/lyra/strict_data_access.rb', line 20

def initialize(method_name, model_class)
  @method_name = method_name
  @model_class = model_class
  @alternative = ALTERNATIVES[method_name.to_sym]

  super(build_message)
end

Instance Attribute Details

#alternative ⇒ Object (readonly)

Returns the value of attribute alternative.



7
8
9
# File 'lib/lyra/strict_data_access.rb', line 7

def alternative
  @alternative
end

#method_name ⇒ Object (readonly)

Returns the value of attribute method_name.



7
8
9
# File 'lib/lyra/strict_data_access.rb', line 7

def method_name
  @method_name
end

#model_class ⇒ Object (readonly)

Returns the value of attribute model_class.



7
8
9
# File 'lib/lyra/strict_data_access.rb', line 7

def model_class
  @model_class
end