Class: ApprovalEngine::ApprovalExposure::Attribute
- Inherits:
-
Struct
- Object
- Struct
- ApprovalEngine::ApprovalExposure::Attribute
- Defined in:
- lib/approval_engine/approval_exposure.rb
Overview
A single whitelisted attribute. ‘source` decides how the value is read:
nil -> read the attribute/method named `name`
Symbol -> call that method on the record
Proc -> call it with the record
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
19 20 21 |
# File 'lib/approval_engine/approval_exposure.rb', line 19 def name @name end |
#source ⇒ Object
Returns the value of attribute source
19 20 21 |
# File 'lib/approval_engine/approval_exposure.rb', line 19 def source @source end |
#type ⇒ Object
Returns the value of attribute type
19 20 21 |
# File 'lib/approval_engine/approval_exposure.rb', line 19 def type @type end |
Instance Method Details
#value_for(record) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/approval_engine/approval_exposure.rb', line 20 def value_for(record) case source when nil then record.public_send(name) when Symbol then record.public_send(source) when Proc then source.call(record) else source end end |