Class: Punchblock::Event::Asterisk::AMI::Event

Inherits:
Punchblock::Event show all
Defined in:
lib/punchblock/event/asterisk/ami/event.rb

Defined Under Namespace

Classes: Attribute

Instance Attribute Summary

Attributes inherited from RayoNode

#call_id, #client, #component_id, #connection, #domain, #mixer_name, #original_component

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Class Method Details

.new(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 10

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair { |k,v| new_node.send :"#{k}=", v }
  end
end

Instance Method Details

#attributesArray[Attribute]

Returns attributes.

Returns:



37
38
39
40
41
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 37

def attributes
  find('//ns:attribute', :ns => self.class.registered_ns).map do |i|
    Attribute.new i
  end
end

#attributes=(attributes) ⇒ Object

Parameters:

  • attributes (Hash, Array)

    A hash of key-value attribute pairs, or an array of Attribute objects



46
47
48
49
50
51
52
53
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 46

def attributes=(attributes)
  find('//ns:attribute', :ns => self.class.registered_ns).each &:remove
  if attributes.is_a? Hash
    attributes.each_pair { |k,v| self << Attribute.new(k, v) }
  elsif attributes.is_a? Array
    [attributes].flatten.each { |i| self << Attribute.new(i) }
  end
end

#attributes_hashHash

Returns hash of key-value pairs of attributes.

Returns:

  • (Hash)

    hash of key-value pairs of attributes



27
28
29
30
31
32
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 27

def attributes_hash
  attributes.inject({}) do |hash, attribute|
    hash[attribute.name] = attribute.value
    hash
  end
end

#inspect_attributesObject

:nodoc:



55
56
57
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 55

def inspect_attributes # :nodoc:
  [:name, :attributes_hash] + super
end

#nameObject



16
17
18
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 16

def name
  read_attr :name
end

#name=(other) ⇒ Object



20
21
22
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 20

def name=(other)
  write_attr :name, other
end