Class: Apiture::RequestContext
- Inherits:
-
Object
- Object
- Apiture::RequestContext
- Includes:
- Utils::Inflections
- Defined in:
- lib/apiture/request_context.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #authenticator ⇒ Object
- #get_attribute(name) ⇒ Object
-
#initialize(options, group, endpoint, attributes) ⇒ RequestContext
constructor
A new instance of RequestContext.
- #logger ⇒ Object
- #perform ⇒ Object
Methods included from Utils::Inflections
acronym_regex, acronyms, #camelize, #constantize, #underscore
Constructor Details
#initialize(options, group, endpoint, attributes) ⇒ RequestContext
Returns a new instance of RequestContext.
20 21 22 |
# File 'lib/apiture/request_context.rb', line 20 def initialize(, group, endpoint, attributes) @options, @group, @endpoint, @attributes = , group, endpoint, attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
18 19 20 |
# File 'lib/apiture/request_context.rb', line 18 def attributes @attributes end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
18 19 20 |
# File 'lib/apiture/request_context.rb', line 18 def endpoint @endpoint end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
18 19 20 |
# File 'lib/apiture/request_context.rb', line 18 def group @group end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/apiture/request_context.rb', line 18 def @options end |
Instance Method Details
#authenticator ⇒ Object
48 49 50 |
# File 'lib/apiture/request_context.rb', line 48 def authenticator group.authenticator end |
#get_attribute(name) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/apiture/request_context.rb', line 56 def get_attribute(name) name = name.to_sym unless attributes.has_key?(name) name = underscore(name).to_sym end attributes[name] end |
#logger ⇒ Object
52 53 54 |
# File 'lib/apiture/request_context.rb', line 52 def logger group.logger end |
#perform ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/apiture/request_context.rb', line 24 def perform url = endpoint.url.dup if url.base_host url.subdomain = [:subdomain] end if [:url_options] url.merge_components([:url_options]) end env = { method: endpoint.request_method, url: url, params: {}, request_headers: {}, logger: logger, context: self } endpoint.middleware_stack.call(env) perform_request(env) end |