Class: Rubeetup::Request
- Inherits:
-
Object
- Object
- Rubeetup::Request
- Includes:
- RequestsCatalog, Utilities
- Defined in:
- lib/rubeetup/request.rb
Overview
Represents API requests. Provides for their own validation and execution
Instance Attribute Summary collapse
-
#http_verb ⇒ Symbol
readonly
Http_verb the http_verb for the request.
-
#method_path ⇒ String
readonly
Method_path the path of the Meetup API resource.
-
#multipart ⇒ Lambda
readonly
Multipart if present it contains the multipart POST logic.
-
#name ⇒ Symbol
readonly
Name the name of the request as input by the user.
-
#options ⇒ Hash{Symbol=>String}
readonly
Options holds the request’s options.
-
#sender ⇒ Rubeetup::Sender
readonly
Sender the request’s chosen sender.
Instance Method Summary collapse
-
#execute ⇒ Array<Rubeetup::ResponseWrapper>
Completes this request.
-
#initialize(args = {}) ⇒ Request
constructor
A new instance of Request.
-
#to_s ⇒ Object
For debugging purposes.
Methods included from Utilities
#blank?, #collection_symbolyzer, #present?, #stringify
Methods included from RequestsCatalog
#is_in_catalog?, #request_multipart, #request_path, #required_options
Constructor Details
#initialize(args = {}) ⇒ Request
Returns a new instance of Request.
47 48 49 50 51 52 53 54 55 |
# File 'lib/rubeetup/request.rb', line 47 def initialize(args = {}) @name = args[:name] @options = args[:options] validate_request @http_verb = args[:http_verb] @method_path = request_path.call(@options) @multipart = request_multipart @sender = Rubeetup::RequestSender.new end |
Instance Attribute Details
#http_verb ⇒ Symbol (readonly)
Returns http_verb the http_verb for the request.
19 20 21 |
# File 'lib/rubeetup/request.rb', line 19 def http_verb @http_verb end |
#method_path ⇒ String (readonly)
Returns method_path the path of the Meetup API resource.
24 25 26 |
# File 'lib/rubeetup/request.rb', line 24 def method_path @method_path end |
#multipart ⇒ Lambda (readonly)
Returns multipart if present it contains the multipart POST logic.
39 40 41 |
# File 'lib/rubeetup/request.rb', line 39 def multipart @multipart end |
#name ⇒ Symbol (readonly)
Returns name the name of the request as input by the user.
14 15 16 |
# File 'lib/rubeetup/request.rb', line 14 def name @name end |
#options ⇒ Hash{Symbol=>String} (readonly)
Returns options holds the request’s options.
29 30 31 |
# File 'lib/rubeetup/request.rb', line 29 def @options end |
#sender ⇒ Rubeetup::Sender (readonly)
Returns sender the request’s chosen sender.
34 35 36 |
# File 'lib/rubeetup/request.rb', line 34 def sender @sender end |
Instance Method Details
#execute ⇒ Array<Rubeetup::ResponseWrapper>
Completes this request
61 62 63 |
# File 'lib/rubeetup/request.rb', line 61 def execute sender.get_response(self) end |
#to_s ⇒ Object
For debugging purposes
68 69 70 71 72 73 74 75 76 |
# File 'lib/rubeetup/request.rb', line 68 def to_s <<-DOC.gsub(/^ {8}/, '') \nREQUEST name => #{name} verb => #{http_verb} path => #{method_path} options => #{.inspect}\n DOC end |