Class: BooticClient::Strategies::Strategy
- Inherits:
-
Object
- Object
- BooticClient::Strategies::Strategy
show all
- Defined in:
- lib/bootic_client/strategies/strategy.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config, client_opts = {}, &on_new_token) ⇒ Strategy
Returns a new instance of Strategy.
7
8
9
10
11
|
# File 'lib/bootic_client/strategies/strategy.rb', line 7
def initialize(config, client_opts = {}, &on_new_token)
@config, @options, @on_new_token = config, client_opts, (on_new_token || Proc.new{})
raise ArgumentError, 'must include a Configuration object' unless config
validate!
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5
6
7
|
# File 'lib/bootic_client/strategies/strategy.rb', line 5
def options
@options
end
|
Instance Method Details
#from_hash(hash, wrapper_class = Entity) ⇒ Object
17
18
19
|
# File 'lib/bootic_client/strategies/strategy.rb', line 17
def from_hash(hash, wrapper_class = Entity)
wrapper_class.new hash, self
end
|
#from_url(url) ⇒ Object
21
22
23
|
# File 'lib/bootic_client/strategies/strategy.rb', line 21
def from_url(url)
request_and_wrap :get, url
end
|
#inspect ⇒ Object
33
34
35
|
# File 'lib/bootic_client/strategies/strategy.rb', line 33
def inspect
%(#<#{self.class.name} root: #{config.api_root}>)
end
|
#request_and_wrap(request_method, href, payload = {}) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/bootic_client/strategies/strategy.rb', line 25
def request_and_wrap(request_method, href, payload = {})
pre_flight
retryable do
resp = client.send(request_method, href, payload, )
config.response_handlers.resolve(resp, self)
end
end
|
#root ⇒ Object
13
14
15
|
# File 'lib/bootic_client/strategies/strategy.rb', line 13
def root
request_and_wrap :get, config.api_root
end
|