Class: Fabricio::Networking::RequestModel
- Inherits:
-
Object
- Object
- Fabricio::Networking::RequestModel
- Defined in:
- lib/fabricio/networking/request_model.rb
Overview
A data structure that provides all values necessary for making an API request
Instance Attribute Summary collapse
-
#api_path ⇒ Object
Returns the value of attribute api_path.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#params ⇒ Object
Returns the value of attribute params.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(options = { :type => :GET, :base_url => '', :api_path => '', :headers => {}, :body => nil, :params => {} }) {|_self| ... } ⇒ Fabricio::Networking::RequestModel
constructor
Initializes a new RequestModel object.
Constructor Details
#initialize(options = { :type => :GET, :base_url => '', :api_path => '', :headers => {}, :body => nil, :params => {} }) {|_self| ... } ⇒ Fabricio::Networking::RequestModel
Initializes a new RequestModel object. You can use a block to fill all the options: model = Fabricio::Networking::RequestModel.new do |config|
config.type = :GET
config.base_url = FABRIC_API_URL
config.api_path = '/apps'
end
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fabricio/networking/request_model.rb', line 23 def initialize( = { :type => :GET, :base_url => '', :api_path => '', :headers => {}, :body => nil, :params => {} }) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end |
Instance Attribute Details
#api_path ⇒ Object
Returns the value of attribute api_path.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def api_path @api_path end |
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def base_url @base_url end |
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def headers @headers end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def params @params end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/fabricio/networking/request_model.rb', line 6 def type @type end |