Module: APIClientBase::Response
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/api_client_base/response.rb
Class Method Summary collapse
Instance Method Summary collapse
- #default_body ⇒ Object
- #default_code ⇒ Object
- #default_headers ⇒ Object
- #default_success ⇒ Object
- #header(key) ⇒ Object
Class Method Details
.module(opts = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/api_client_base/response.rb', line 4 def self.module(opts={}) mod = Module.new do mattr_accessor :api_client_base_response_options def self.included(base) base.class_attribute :api_client_base_response_options base. = self. base.send :include, APIClientBase::Response end end mod. = opts mod end |
Instance Method Details
#default_body ⇒ Object
40 41 42 |
# File 'lib/api_client_base/response.rb', line 40 def default_body raw_response.body end |
#default_code ⇒ Object
36 37 38 |
# File 'lib/api_client_base/response.rb', line 36 def default_code raw_response.code end |
#default_headers ⇒ Object
44 45 46 |
# File 'lib/api_client_base/response.rb', line 44 def default_headers (raw_response.headers || {}).transform_keys {|key| key.upcase } end |
#default_success ⇒ Object
32 33 34 |
# File 'lib/api_client_base/response.rb', line 32 def default_success raw_response.success? end |
#header(key) ⇒ Object
48 49 50 |
# File 'lib/api_client_base/response.rb', line 48 def header(key) headers[key.upcase] end |