Class: Acfs::Request
- Inherits:
-
Object
- Object
- Acfs::Request
- Includes:
- Callbacks
- Defined in:
- lib/acfs/request.rb,
lib/acfs/request/callbacks.rb
Overview
Encapsulate all data required to make up a request to the underlaying http library.
Defined Under Namespace
Modules: Callbacks
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#format ⇒ Object
Returns the value of attribute format.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #data? ⇒ Boolean
-
#initialize(url, **options, &block) ⇒ Request
constructor
A new instance of Request.
Methods included from Callbacks
#callbacks, #complete!, #on_complete
Constructor Details
#initialize(url, **options, &block) ⇒ Request
Returns a new instance of Request.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/acfs/request.rb', line 14 def initialize(url, **, &block) @url = URI.parse(url.to_s).tap do |_url| @data = .delete(:data) || nil @format = .delete(:format) || :json @headers = .delete(:headers) || {} @params = .delete(:params) || {} @method = .delete(:method) || :get end.to_s @operation = .delete(:operation) || nil on_complete(&block) if block end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/acfs/request.rb', line 10 def body @body end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def data @data end |
#format ⇒ Object
Returns the value of attribute format.
10 11 12 |
# File 'lib/acfs/request.rb', line 10 def format @format end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def method @method end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def operation @operation end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def params @params end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/acfs/request.rb', line 11 def url @url end |
Instance Method Details
#data? ⇒ Boolean
28 29 30 |
# File 'lib/acfs/request.rb', line 28 def data? !data.nil? end |