Class: Preposterous::Request
- Inherits:
-
Object
- Object
- Preposterous::Request
- Extended by:
- Forwardable
- Defined in:
- lib/preposterous/request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, method, path, options = {}) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(client, method, path, options = {}) ⇒ Request
Returns a new instance of Request.
16 17 18 |
# File 'lib/preposterous/request.rb', line 16 def initialize(client, method, path, ={}) @client, @method, @path, @options = client, method, path, end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/preposterous/request.rb', line 6 def client @client end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/preposterous/request.rb', line 6 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/preposterous/request.rb', line 6 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/preposterous/request.rb', line 6 def path @path end |
Class Method Details
.get(client, path, options = {}) ⇒ Object
8 9 10 |
# File 'lib/preposterous/request.rb', line 8 def self.get(client, path, ={}) new(client, :get, path, ).perform end |
.post(client, path, options = {}) ⇒ Object
12 13 14 |
# File 'lib/preposterous/request.rb', line 12 def self.post(client, path, ={}) new(client, :post, path, ).perform end |
Instance Method Details
#perform ⇒ Object
31 32 33 |
# File 'lib/preposterous/request.rb', line 31 def perform Preposterous.make_friendly(send("perform_#{method}")) end |
#uri ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/preposterous/request.rb', line 20 def uri @uri ||= begin uri = URI.parse(path) if [:fields] && [:fields] != {} uri.query = to_query([:fields]) end uri.to_s end end |