Class: Punchblock::Component::ComponentNode
- Inherits:
-
Punchblock::CommandNode
- Object
- Niceogiri::XML::Node
- RayoNode
- Punchblock::CommandNode
- Punchblock::Component::ComponentNode
- Includes:
- HasGuardedHandlers
- Defined in:
- lib/punchblock/component.rb
Direct Known Subclasses
Input, Output, Record, Tropo::Ask, Tropo::Conference, Tropo::Say, Tropo::Transfer
Instance Attribute Summary collapse
-
#complete_event ⇒ Object
Returns the value of attribute complete_event.
Attributes inherited from RayoNode
#call_id, #client, #component_id, #connection, #original_component
Instance Method Summary collapse
- #add_event(event) ⇒ Object
-
#initialize(*args) ⇒ ComponentNode
constructor
A new instance of ComponentNode.
- #register_event_handler(*guards, &block) ⇒ Object
- #register_initial_handlers ⇒ Object
- #response=(other) ⇒ Object
-
#stop!(options = {}) ⇒ Object
Sends an Rayo stop message for the current component.
-
#stop_action ⇒ Stop
Create an Rayo stop message.
- #write_action(action) ⇒ Object
Methods inherited from Punchblock::CommandNode
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, #inspect_attributes, new, register, #source
Constructor Details
#initialize(*args) ⇒ ComponentNode
Returns a new instance of ComponentNode.
17 18 19 20 21 |
# File 'lib/punchblock/component.rb', line 17 def initialize(*args) super @complete_event = FutureResource.new register_initial_handlers end |
Instance Attribute Details
#complete_event ⇒ Object
Returns the value of attribute complete_event.
15 16 17 |
# File 'lib/punchblock/component.rb', line 15 def complete_event @complete_event end |
Instance Method Details
#add_event(event) ⇒ Object
31 32 33 34 |
# File 'lib/punchblock/component.rb', line 31 def add_event(event) event.original_component = self trigger_handler :event, event end |
#register_event_handler(*guards, &block) ⇒ Object
36 37 38 |
# File 'lib/punchblock/component.rb', line 36 def register_event_handler(*guards, &block) register_handler :event, *guards, &block end |
#register_initial_handlers ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/punchblock/component.rb', line 23 def register_initial_handlers register_event_handler Event::Complete do |event| complete! complete_event.resource = event throw :pass end end |
#response=(other) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/punchblock/component.rb', line 45 def response=(other) if other.is_a?(Ref) @component_id = other.id client.register_component self end super end |
#stop!(options = {}) ⇒ Object
Sends an Rayo stop message for the current component
65 66 67 68 |
# File 'lib/punchblock/component.rb', line 65 def stop!( = {}) raise InvalidActionError, "Cannot stop a #{self.class.name.split("::").last} that is not executing" unless executing? stop_action.tap { |action| write_action action } end |
#stop_action ⇒ Stop
Create an Rayo stop message
58 59 60 |
# File 'lib/punchblock/component.rb', line 58 def stop_action Stop.new :component_id => component_id, :call_id => call_id end |
#write_action(action) ⇒ Object
40 41 42 43 |
# File 'lib/punchblock/component.rb', line 40 def write_action(action) client.execute_command action, :call_id => call_id, :component_id => component_id action end |