Class: YaMetrika::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ya_metrika/client.rb

Constant Summary collapse

HOST =
'http://api-metrika.yandex.ru'
REST_METHODS =
[:get, :post, :put, :delete]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/ya_metrika/client.rb', line 9

def initialize(options = {})
  options = YaMetrika::Settings.to_hash.merge(options)
  @format = options[:format]
  @oauth_token = options[:oauth_token]

  @spells = Array.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



17
18
19
20
21
22
23
24
25
# File 'lib/ya_metrika/client.rb', line 17

def method_missing(meth, *args, &block)
  if YaMetrika::Client::REST_METHODS.include?(meth.to_sym)
    rest(meth, *args, &block)
  else
    @spells << meth.to_s
    @spells << args.first.to_s if args.first
    self
  end
end