Class: ApprovalEngine::ApprovalExposure::Attribute

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



19
20
21
# File 'lib/approval_engine/approval_exposure.rb', line 19

def name
  @name
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



19
20
21
# File 'lib/approval_engine/approval_exposure.rb', line 19

def source
  @source
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of 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