Module: Twilio::TwiML

Extended by:
TwiML
Included in:
TwiML
Defined in:
lib/twilio/twiml.rb

Instance Method Summary collapse

Instance Method Details

#build(&blk) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/twilio/twiml.rb', line 3

def build &blk
  xm = Builder::XmlMarkup.new(:indent => 2)
  xm.instance_eval do
    def method_missing(meth, *args, &blk)
      # camelize options
      if args.last.kind_of? ::Hash
        args[-1] = ::Hash[args.last.map { |k,v| [k.to_s.camelize(:lower), v]}]
      end
      # let builder do the heavy lifting
      super(meth.to_s.capitalize, *args, &blk)
    end
  end
  xm.instruct!
  xm.response &blk
end