Class: Hollaback::Callback
- Inherits:
-
Object
- Object
- Hollaback::Callback
- Defined in:
- lib/hollaback/callback.rb
Instance Attribute Summary collapse
-
#executable ⇒ Object
readonly
Returns the value of attribute executable.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(type, execute = nil, &block) ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize(type, execute = nil, &block) ⇒ Callback
Returns a new instance of Callback.
5 6 7 8 |
# File 'lib/hollaback/callback.rb', line 5 def initialize(type, execute = nil, &block) @type = type @executable = (execute ? execute : block) end |
Instance Attribute Details
#executable ⇒ Object (readonly)
Returns the value of attribute executable.
3 4 5 |
# File 'lib/hollaback/callback.rb', line 3 def executable @executable end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/hollaback/callback.rb', line 3 def type @type end |
Instance Method Details
#build ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/hollaback/callback.rb', line 10 def build case executable when Symbol -> (target, &block) { target.send(executable, &block) } when Proc -> (target) { target.instance_eval(&executable) } end end |