Class: Typhoid::RequestBuilder
- Inherits:
-
Object
- Object
- Typhoid::RequestBuilder
- Defined in:
- lib/typhoid/request_builder.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#method ⇒ Object
writeonly
Sets the attribute method.
-
#request_options ⇒ Object
Returns the value of attribute request_options.
-
#request_uri ⇒ Object
Returns the value of attribute request_uri.
Instance Method Summary collapse
- #http_method ⇒ Object
-
#initialize(klass, uri, options = {}) ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
- #options ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(klass, uri, options = {}) ⇒ RequestBuilder
Returns a new instance of RequestBuilder.
9 10 11 12 13 |
# File 'lib/typhoid/request_builder.rb', line 9 def initialize(klass, uri, = {}) self.request_uri = uri self. = || {} self.klass = klass end |
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/typhoid/request_builder.rb', line 3 def klass @klass end |
#method=(value) ⇒ Object (writeonly)
Sets the attribute method
7 8 9 |
# File 'lib/typhoid/request_builder.rb', line 7 def method=(value) @method = value end |
#request_options ⇒ Object
Returns the value of attribute request_options.
4 5 6 |
# File 'lib/typhoid/request_builder.rb', line 4 def @request_options end |
#request_uri ⇒ Object
Returns the value of attribute request_uri.
5 6 7 |
# File 'lib/typhoid/request_builder.rb', line 5 def request_uri @request_uri end |
Instance Method Details
#http_method ⇒ Object
19 20 21 |
# File 'lib/typhoid/request_builder.rb', line 19 def http_method [:method] || :get end |
#options ⇒ Object
15 16 17 |
# File 'lib/typhoid/request_builder.rb', line 15 def symbolize_keys({ method: http_method }.merge(.reject { |_,value| value.nil? })) end |
#run ⇒ Object
23 24 25 |
# File 'lib/typhoid/request_builder.rb', line 23 def run klass.run(self) end |