Class: Ya::Direct::Api
- Inherits:
-
Object
- Object
- Ya::Direct::Api
- Defined in:
- lib/ya_direct_api.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
Instance Method Summary collapse
-
#initialize(token, app_id, login, locale = 'en') ⇒ Api
constructor
A new instance of Api.
- #method_missing(method_name, args = {}) ⇒ Object
- #resolve_env ⇒ Object
Constructor Details
#initialize(token, app_id, login, locale = 'en') ⇒ Api
Returns a new instance of Api.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ya_direct_api.rb', line 13 def initialize(token, app_id, login, locale = 'en') @config = { token: token, app_id: app_id, login: login, locale: locale } @env = resolve_env @gateway = Ya::Direct::Gateway.new(@env, @config) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, args = {}) ⇒ Object
24 25 26 |
# File 'lib/ya_direct_api.rb', line 24 def method_missing(method_name, args = {}) @gateway.get_data(method_name.to_s.camelize, args) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/ya_direct_api.rb', line 11 def config @config end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/ya_direct_api.rb', line 11 def env @env end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
11 12 13 |
# File 'lib/ya_direct_api.rb', line 11 def gateway @gateway end |
Instance Method Details
#resolve_env ⇒ Object
28 29 30 |
# File 'lib/ya_direct_api.rb', line 28 def resolve_env ENV['RAILS_ENV'] || 'development' end |