Class: AppStoreDevApi::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/app_store_dev_api/base.rb

Direct Known Subclasses

Client

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
# File 'lib/app_store_dev_api/base.rb', line 5

def initialize(**kwargs)
  @options = Client::Options.new(kwargs)
  @authorization = Client::Authorization.new(@options.slice(*Client::Authorization::OPTIONS))
  @registry = Client::Registry.new(@options.slice(*Client::Registry::OPTIONS))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, **kwargs) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/app_store_dev_api/base.rb', line 15

def method_missing(method_name, **kwargs)
  super unless web_service_endpoint_aliases.include?(method_name)

  web_service_endpoint = web_service_endpoint_by(method_name)

  call(web_service_endpoint, **kwargs)
end

Instance Method Details

#inspectObject

:nocov:



24
25
26
# File 'lib/app_store_dev_api/base.rb', line 24

def inspect
  "#<#{self.class.name}:#{object_id}>"
end

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/app_store_dev_api/base.rb', line 11

def respond_to_missing?(method_name, include_private = false)
  web_service_endpoint_aliases.include?(method_name) || super
end

#web_service_endpoint_aliasesObject

:nocov:



29
30
31
# File 'lib/app_store_dev_api/base.rb', line 29

def web_service_endpoint_aliases
  @registry.keys
end