Module: Twilio::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/twilio/config.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



16
17
18
19
# File 'lib/twilio/config.rb', line 16

def method_missing(meth, *args, &blk)
  const = meth.to_s.upcase
  Twilio.const_set(const, args.first) unless Twilio.const_defined? const
end

Instance Method Details

#setup(opts = {}, &blk) ⇒ Object



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

def setup(opts={}, &blk)
  if block_given?
    instance_eval &blk
    warn 'The block syntax for configuration is deprecated. Use an options hash instead, e.g. Twilio::Config.setup account_sid: "AC00000000000000000000000", auth_token: "xxxxxxxxxxxxxxxxxxx"'
  else
    opts.map do |k,v|
      const = k.to_s.upcase
      Twilio.const_set(const, v) unless Twilio.const_defined? const
    end
  end

end