Module: Twilio::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



37
38
39
40
# File 'lib/twilio/config.rb', line 37

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

Instance Attribute Details

#account_sidObject



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

def 
  if @account_sid
    @account_sid
  else
    raise Twilio::ConfigurationError.new \
      "Cannot complete request. Please set account_sid with Twilio::Config.setup first!"
  end
end

#auth_tokenObject



16
17
18
19
20
21
22
23
# File 'lib/twilio/config.rb', line 16

def auth_token
  if @auth_token
    @auth_token
  else
    raise Twilio::ConfigurationError.new \
      "Cannot complete request. Please set auth_token with Twilio::Config.setup first!"
  end
end

Instance Method Details

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



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/twilio/config.rb', line 25

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|
      send("#{k}=", v)
    end
  end

end