Class: Pupper::Backend
- Inherits:
-
Object
- Object
- Pupper::Backend
- Defined in:
- lib/pupper/backend.rb
Overview
Provides an interface to build an API Client, that can be used by [Model]
Defined Under Namespace
Classes: BaseUrlNotDefined
Class Attribute Summary collapse
-
.base_url ⇒ String
writeonly
Sets the base URL the API client will call.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize ⇒ Backend
constructor
A new instance of Backend.
- #register_model(model) ⇒ Object
Constructor Details
#initialize ⇒ Backend
Returns a new instance of Backend.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pupper/backend.rb', line 42 def initialize @client = Faraday.new(base_url, ssl: { verify: Rails.env.production? }) do |builder| builder.request :json builder.use Pupper::ParseJson builder.response :logger if Rails.env.development? builder.response :raise_error builder.adapter :typhoeus builder.headers['User-Agent'] = Pupper.config.user_agent end end |
Class Attribute Details
.base_url=(value) ⇒ String
Sets the base URL the API client will call
15 16 17 |
# File 'lib/pupper/backend.rb', line 15 def base_url=(value) @base_url = value end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/pupper/backend.rb', line 8 def client @client end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/pupper/backend.rb', line 8 def model @model end |
Instance Method Details
#register_model(model) ⇒ Object
53 54 55 |
# File 'lib/pupper/backend.rb', line 53 def register_model(model) @model = model end |