Class: Sofia::Request
- Inherits:
-
Object
- Object
- Sofia::Request
- Defined in:
- lib/sofia/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
: Sofia::Types::Body.
-
#headers ⇒ Object
: Sofia::Types::Headers.
-
#http_method ⇒ Object
readonly
: Symbol.
-
#params ⇒ Object
: Sofia::Types::Params.
Instance Method Summary collapse
-
#initialize(http_method:, base_url:) ⇒ Request
constructor
: (http_method: Symbol, base_url: Sofia::Types::BaseUrl) -> void.
-
#path=(path) ⇒ Object
: (untyped path) -> void.
-
#url ⇒ Object
: -> String.
Constructor Details
#initialize(http_method:, base_url:) ⇒ Request
: (http_method: Symbol, base_url: Sofia::Types::BaseUrl) -> void
20 21 22 23 24 25 26 27 |
# File 'lib/sofia/request.rb', line 20 def initialize(http_method:, base_url:) @http_method = http_method @base_url = base_url @path = Sofia::Types::Path.new #: Sofia::Types::Path @params = Sofia::Types::Params.new #: Sofia::Types::Params @headers = Sofia::Types::Headers.new #: Sofia::Types::Headers @body = Sofia::Types::Body.new #: Sofia::Types::Body end |
Instance Attribute Details
#body ⇒ Object
: Sofia::Types::Body
17 18 19 |
# File 'lib/sofia/request.rb', line 17 def body @body end |
#headers ⇒ Object
: Sofia::Types::Headers
11 12 13 |
# File 'lib/sofia/request.rb', line 11 def headers @headers end |
#http_method ⇒ Object (readonly)
: Symbol
8 9 10 |
# File 'lib/sofia/request.rb', line 8 def http_method @http_method end |
#params ⇒ Object
: Sofia::Types::Params
14 15 16 |
# File 'lib/sofia/request.rb', line 14 def params @params end |
Instance Method Details
#path=(path) ⇒ Object
: (untyped path) -> void
30 31 32 |
# File 'lib/sofia/request.rb', line 30 def path=(path) @path = Sofia::Types::Path.new(path) end |
#url ⇒ Object
: -> String
50 51 52 53 54 |
# File 'lib/sofia/request.rb', line 50 def url qs = @params.to_s base = @base_url.to_s + @path.to_s qs.empty? ? base : "#{base}?#{qs}" end |