Module: Bandwidth::Voice::XmlVerb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb', line 8

def method_missing(name, *args, &block)
  if name[name.size - 1] == '='
    @data[name[0..-2].to_sym] = args[0]
  else
    @data[name]
  end
end

Instance Method Details

#compact_hash(hash) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb', line 16

def compact_hash(hash)
  hash.inject({}) do |new_hash, (k,v)|
    if !v.nil?
      new_hash[k] = v.class == Hash ? compact_hash(v) : v
    end
    new_hash
  end
end

#initialize(data = nil) ⇒ Object



4
5
6
# File 'lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb', line 4

def initialize(data = nil)
  @data = (data || {}).clone()
end