Class: Upkeep::Dependencies::ActiveRecordAttribute

Inherits:
Base
  • Object
show all
Defined in:
lib/upkeep/dependencies.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #metadata, #source

Instance Method Summary collapse

Methods inherited from Base

#cache_key, #identity?, #identity_key, #to_h, #visibility

Constructor Details

#initialize(table:, id:, attribute:, model: nil) ⇒ ActiveRecordAttribute

Returns a new instance of ActiveRecordAttribute.



57
58
59
60
61
62
63
# File 'lib/upkeep/dependencies.rb', line 57

def initialize(table:, id:, attribute:, model: nil)
  super(
    source: :active_record_attribute,
    key: { table: table, id: id, attribute: attribute },
    metadata: { model: model }.compact
  )
end

Instance Method Details

#matches_change?(change) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
68
69
# File 'lib/upkeep/dependencies.rb', line 65

def matches_change?(change)
  key.fetch(:table) == change.fetch(:table) &&
    (!change[:id] || key.fetch(:id) == change[:id]) &&
    change.fetch(:changed_attributes, []).include?(key.fetch(:attribute))
end

#narrow_frame_safe?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/upkeep/dependencies.rb', line 75

def narrow_frame_safe?
  true
end

#precisionObject



71
72
73
# File 'lib/upkeep/dependencies.rb', line 71

def precision
  :record_attribute
end