Class: Phearb::Agent
- Inherits:
-
Object
- Object
- Phearb::Agent
- Defined in:
- lib/phearb/agent.rb
Instance Method Summary collapse
- #fetch(options = {}) ⇒ Object
-
#initialize(url) ⇒ Agent
constructor
A new instance of Agent.
Constructor Details
#initialize(url) ⇒ Agent
Returns a new instance of Agent.
8 9 10 |
# File 'lib/phearb/agent.rb', line 8 def initialize(url) @url = url end |
Instance Method Details
#fetch(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/phearb/agent.rb', line 12 def fetch( = {}) params = .merge(fetch_url: @url) Timeout::timeout(Phearb.configuration.timeout.to_f) do http_response = RestClient.get(server_url, params: params) Response.from_json(http_response) end rescue Timeout::Error => exception raise Error::Timeout end |