Class: Hactor::HTTP::Client
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Hactor::HTTP::Client
- Defined in:
- lib/hactor/http/client.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#response_class ⇒ Object
readonly
Returns the value of attribute response_class.
Instance Method Summary collapse
- #follow(link, options = {}) ⇒ Object
- #get(options) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
7 8 9 |
# File 'lib/hactor/http/client.rb', line 7 def backend @backend end |
#response_class ⇒ Object (readonly)
Returns the value of attribute response_class.
7 8 9 |
# File 'lib/hactor/http/client.rb', line 7 def response_class @response_class end |
Instance Method Details
#follow(link, options = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hactor/http/client.rb', line 15 def follow(link, = {}) actor = .fetch(:actor) context_url = .fetch(:context_url) url = context_url.merge(link.href) get(url: url, actor: actor) end |
#get(options) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hactor/http/client.rb', line 23 def get() url = .fetch :url actor = .fetch :actor response = response_class.new(backend.get(url), http_client: self) actor.call response end |