Class: Julia::Action
- Inherits:
-
Object
- Object
- Julia::Action
- Defined in:
- lib/julia/action.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #get_value(record) ⇒ Object
-
#initialize(key, action = nil, &block) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(key, action = nil, &block) ⇒ Action
Returns a new instance of Action.
5 6 7 8 9 |
# File 'lib/julia/action.rb', line 5 def initialize(key, action = nil, &block) @key = key @action = action @block = block end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/julia/action.rb', line 3 def action @action end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/julia/action.rb', line 3 def block @block end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/julia/action.rb', line 3 def key @key end |
Instance Method Details
#get_value(record) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/julia/action.rb', line 11 def get_value(record) return block.call(record) if block return record.instance_exec(&action) if action.is_a? Proc record.send [action, key].compact.first end |