Class: ModelAuditor::AttributeReader

Inherits:
Object
  • Object
show all
Defined in:
lib/model_auditor/attribute_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, key) ⇒ AttributeReader

Returns a new instance of AttributeReader.



7
8
9
10
# File 'lib/model_auditor/attribute_reader.rb', line 7

def initialize(model, key)
  @model = model
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/model_auditor/attribute_reader.rb', line 5

def key
  @key
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/model_auditor/attribute_reader.rb', line 5

def model
  @model
end

Instance Method Details

#valueObject



12
13
14
# File 'lib/model_auditor/attribute_reader.rb', line 12

def value
  associated_attr_value || array_attr_value || model.send(key)
end