Module: Upkeep::Runtime::AttributeObserver

Defined in:
lib/upkeep/runtime.rb

Instance Method Summary collapse

Instance Method Details

#_read_attribute(attr_name, &block) ⇒ Object



753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
# File 'lib/upkeep/runtime.rb', line 753

def _read_attribute(attr_name, &block)
  value = super
  return value unless Observation.recording?

  dependency = Dependencies::ActiveRecordAttribute.new(
    table: self.class.table_name,
    model: self.class.name,
    id: primary_key_value(attr_name, value),
    attribute: attr_name.to_s
  )

  Observation.record_dependency(dependency)

  value
end