Class: ModelAuditor::AttributeReaders::Associated

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

Direct Known Subclasses

ArrayField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, key) ⇒ Associated

Returns a new instance of Associated.



8
9
10
11
# File 'lib/model_auditor/attribute_readers/associated.rb', line 8

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/model_auditor/attribute_readers/associated.rb', line 6

def key
  @key
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/model_auditor/attribute_readers/associated.rb', line 6

def model
  @model
end

Instance Method Details

#valueObject



13
14
15
16
17
# File 'lib/model_auditor/attribute_readers/associated.rb', line 13

def value
  return unless method_name

  model.send(method_name)&.title
end