Module: Cardiac::RequestMethods
- Included in:
- Resource
- Defined in:
- lib/cardiac/resource/request_methods.rb
Constant Summary collapse
- DEFAULT_ACCEPTS =
The default accepts header type identifiers.
[:json, :xml]
Instance Method Summary collapse
- #accepts(search, *rest) ⇒ Object
-
#at(rel, options = {}) ⇒ Object
Relative resource selection.
- #header(key, value) ⇒ Object
-
#headers(h, *rest) ⇒ Object
Header selection.
-
#http_method(k) ⇒ Object
HTTP method selection.
- #option(key, value) ⇒ Object
-
#options(o, *rest) ⇒ Object
Request option selection.
-
#request_has_body? ⇒ Boolean
Checking if the configured HTTP verb has requests that support a body.
-
#request_is_idemptotent? ⇒ Boolean
Checking if the configured HTTP verb should be considered idempotent.
-
#request_is_safe? ⇒ Boolean
Checking if the configured HTTP verb should be considered safe.
- #reset_headers(*h) ⇒ Object
- #reset_options(*o) ⇒ Object
-
#response_has_body? ⇒ Boolean
Checking if the configured HTTP verb has responses that support a body.
Instance Method Details
#accepts(search, *rest) ⇒ Object
23 |
# File 'lib/cardiac/resource/request_methods.rb', line 23 def accepts(search,*rest) self.accepts_values += check_accepts(rest.unshift(search)) ; self end |
#at(rel, options = {}) ⇒ Object
Relative resource selection.
36 37 38 |
# File 'lib/cardiac/resource/request_methods.rb', line 36 def at(rel,={}) super(rel).() end |
#header(key, value) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cardiac/resource/request_methods.rb', line 17 def header(key, value) raise ArgumentError unless String===key or Symbol===key raise ArgumentError if TrueClass===value self.headers_values << (FalseClass===value ? key : {key => value}) self end |
#headers(h, *rest) ⇒ Object
Header selection.
15 |
# File 'lib/cardiac/resource/request_methods.rb', line 15 def headers(h,*rest) self.headers_values += check_headers(rest.unshift(h)) ; self end |
#http_method(k) ⇒ Object
HTTP method selection.
12 |
# File 'lib/cardiac/resource/request_methods.rb', line 12 def http_method(k) self.method_value = check_http_method(k) ; self end |
#option(key, value) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cardiac/resource/request_methods.rb', line 28 def option(key, value) raise ArgumentError unless String===key or Symbol===key raise ArgumentError if TrueClass===value self. << (FalseClass===value ? key : {key => value}) self end |
#options(o, *rest) ⇒ Object
Request option selection.
26 |
# File 'lib/cardiac/resource/request_methods.rb', line 26 def (o,*rest) self. += ((rest.unshift(o))) ; self end |
#request_has_body? ⇒ Boolean
Checking if the configured HTTP verb has requests that support a body.
53 54 55 |
# File 'lib/cardiac/resource/request_methods.rb', line 53 def request_has_body? net_http_request_klass::REQUEST_HAS_BODY end |
#request_is_idemptotent? ⇒ Boolean
Checking if the configured HTTP verb should be considered idempotent.
42 43 44 |
# File 'lib/cardiac/resource/request_methods.rb', line 42 def request_is_idemptotent? case method_value when :get, :head, :options, :put, :delete then true end end |
#request_is_safe? ⇒ Boolean
Checking if the configured HTTP verb should be considered safe.
48 49 50 |
# File 'lib/cardiac/resource/request_methods.rb', line 48 def request_is_safe? case method_value when :get, :head, :options then true end end |
#reset_headers(*h) ⇒ Object
16 |
# File 'lib/cardiac/resource/request_methods.rb', line 16 def reset_headers(*h) headers_values.replace check_headers(h) ; self end |
#reset_options(*o) ⇒ Object
27 |
# File 'lib/cardiac/resource/request_methods.rb', line 27 def (*o) .replace ((o)) ; self end |
#response_has_body? ⇒ Boolean
Checking if the configured HTTP verb has responses that support a body.
58 59 60 |
# File 'lib/cardiac/resource/request_methods.rb', line 58 def response_has_body? net_http_request_klass::RESPONSE_HAS_BODY end |