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

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

Constant Summary

Constant Summary

Constants inherited from Component

Component::OptionError

Instance Attribute Summary (collapse)

Attributes inherited from Component

#call, #id, #internal

Instance Method Summary (collapse)

Methods inherited from Component

#call_id, #execute_command, #logger_id, #send_complete_event, #send_event

Constructor Details

- (AMIAction) initialize(component_node, translator)

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

- (Object) action (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

- (Object) translator (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

- (Object) execute



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

def execute
  send_action
  send_ref
end

- (Object) handle_response(response)



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

def handle_response(response)
  pb_logger.debug "Handling response #{response.inspect}"
  case response
  when RubyAMI::Error
    send_complete_event error_reason(response)
  when RubyAMI::Response
    send_events
    send_complete_event success_reason(response)
  end
end

- (Object) setup



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