Class: Statesman::Callback
- Inherits:
-
Object
- Object
- Statesman::Callback
- Defined in:
- lib/statesman/callback.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #applies_to?(options = { from: nil, to: nil }) ⇒ Boolean
- #call(*args) ⇒ Object
-
#initialize(options = { from: nil, to: nil, callback: nil }) ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize(options = { from: nil, to: nil, callback: nil }) ⇒ Callback
Returns a new instance of Callback.
9 10 11 12 13 14 15 16 17 |
# File 'lib/statesman/callback.rb', line 9 def initialize( = { from: nil, to: nil, callback: nil }) unless [:callback].respond_to?(:call) raise InvalidCallbackError, "No callback passed" end @from = [:from] @to = [:to] @callback = [:callback] end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
7 8 9 |
# File 'lib/statesman/callback.rb', line 7 def callback @callback end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/statesman/callback.rb', line 5 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/statesman/callback.rb', line 6 def to @to end |
Instance Method Details
#applies_to?(options = { from: nil, to: nil }) ⇒ Boolean
23 24 25 |
# File 'lib/statesman/callback.rb', line 23 def applies_to?( = { from: nil, to: nil }) matches([:from], [:to]) end |
#call(*args) ⇒ Object
19 20 21 |
# File 'lib/statesman/callback.rb', line 19 def call(*args) callback.call(*args) end |