Class: Punchblock::Translator::Asterisk::Component::Asterisk::AMIAction

Inherits:
Component
  • Object
show all
Defined in:
lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#call, #call_id, #id, #internal

Instance Method Summary collapse

Methods inherited from Component

#call_ended, #execute_command, #logger_id, #send_complete_event, #send_event

Methods included from DeadActorSafety

#safe_from_dead_actors

Constructor Details

#initialize(component_node, translator) ⇒ AMIAction

Returns a new instance of AMIAction.



11
12
13
14
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 11

def initialize(component_node, translator)
  super component_node, nil
  @translator = translator
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



9
10
11
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 9

def action
  @action
end

#translatorObject (readonly)

Returns the value of attribute translator.



9
10
11
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 9

def translator
  @translator
end

Instance Method Details

#executeObject



21
22
23
24
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 21

def execute
  send_action
  send_ref
end

#handle_response(response) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 26

def handle_response(response)
  case response
  when RubyAMI::Error
    send_complete_event error_reason(response)
  when RubyAMI::Response
    send_events
    send_complete_event success_reason(response)
  end
end

#setupObject



16
17
18
19
# File 'lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb', line 16

def setup
  @action = create_action
  @id = @action.action_id
end