Class: Emma::Setup

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/emma.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

keys

Constructor Details

#initialize(account_id = nil, public_key = nil, private_key = nil, debug = false) ⇒ Setup

Returns a new instance of Setup.



17
18
19
20
21
22
# File 'lib/emma.rb', line 17

def initialize( = nil, public_key = nil, private_key = nil, debug = false)
  @account_id =  || ENV['EMMA_ACCOUNT_ID']
  @public_key = public_key || ENV['EMMA_PUBLIC_KEY']
  @private_key = private_key || ENV['EMMA_PRIVATE_KEY']
  @debug = debug
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)



35
36
37
38
# File 'lib/emma.rb', line 35

def method_missing(method_name, *args)
  return super unless client.respond_to?(method_name)
  client.send(method_name, *args)
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



15
16
17
# File 'lib/emma.rb', line 15

def 
  @account_id
end

#debugObject

Returns the value of attribute debug.



15
16
17
# File 'lib/emma.rb', line 15

def debug
  @debug
end

#private_keyObject

Returns the value of attribute private_key.



15
16
17
# File 'lib/emma.rb', line 15

def private_key
  @private_key
end

#public_keyObject

Returns the value of attribute public_key.



15
16
17
# File 'lib/emma.rb', line 15

def public_key
  @public_key
end

Instance Method Details

#clientObject

establish connection



25
26
27
28
# File 'lib/emma.rb', line 25

def client
  @client = Emma::Client.new(options) unless defined?(@client) && @client.hash == options.hash
  @client
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/emma.rb', line 30

def respond_to_missing?(method, include_private = false)
  client.respond_to?(client, include_private)
end