Class: WotApiRu::Client

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

Overview

Class of client for send response to Wargaming.net Public API

Author:

  • Ivan Bondarenko

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Note:

If you call method which undefined as key in WotApiRu::PATH then method raise NoMethodError

This method dynamic call Wargaming.net Public API methods from WotApiRu::PATH values

Raises:

  • (NoMethodError)


11
12
13
14
15
16
17
# File 'lib/wot_api_ru/client.rb', line 11

def method_missing(meth, *args, &block)
  raise NoMethodError, "undefined method #{meth} for #{self.class.to_s}" if WotApiRu::Constants::PATH[meth.to_sym].nil?
  options = args[0] || {}
  options[:application_id] ||= WotApiRu::Settings[:application_id]
  path = WotApiRu::Constants::HOST + WotApiRu::Constants::PATH[meth.to_sym]
  invoke(path, options)
end