Class: Yandex::Webmaster::ApiFactory

Inherits:
Base show all
Extended by:
Forwardable
Defined in:
lib/yandex-webmaster/api_factory.rb

Constant Summary

Constants included from Request

Request::METHODS, Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ACCEPT, Connection::ACCEPT_CHARSET, Connection::ALLOWED_OPTIONS, Connection::CONTENT_TYPE, Connection::USER_AGENT

Instance Attribute Summary collapse

Attributes inherited from Base

#configuration

Attributes included from Authorization

#scopes

Instance Method Summary collapse

Methods inherited from Base

#attributes=, const_missing, define_attributes, #initialize

Methods included from Request

#delete_request, #get_request, #post_request, #put_request, #request

Methods included from Connection

#connection

Methods included from Authorization

#auth_code, #authenticate, #authenticated?, #authorize_url, #oauth, #token

Constructor Details

This class inherits a constructor from Yandex::Webmaster::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/yandex-webmaster/api_factory.rb', line 14

def method_missing(method, *args, &block)      
  if @klass.respond_to?(method)
    args = args.push(self)
    @klass.send(method, *args, &block)
  elsif Array.method_defined?(method)
    self.class.def_delegator :to_a, method
    self.to_a.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



8
9
10
# File 'lib/yandex-webmaster/api_factory.rb', line 8

def klass
  @klass
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/yandex-webmaster/api_factory.rb', line 8

def url
  @url
end

Instance Method Details

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

Returns:

  • (Boolean)


10
11
12
# File 'lib/yandex-webmaster/api_factory.rb', line 10

def respond_to?(method, include_private = false)
  super || Array.method_defined?(method) || @klass.respond_to?(method, include_private)
end

#to_aObject Also known as: all



26
27
28
# File 'lib/yandex-webmaster/api_factory.rb', line 26

def to_a
  @objects ||= self.objects_from_response(self.klass, self.request(:get, self.url), :host)      
end