Class: OdataDuty::ContextWrapper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- OdataDuty::ContextWrapper
- Defined in:
- lib/odata_duty/context_wrapper.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#caller_context ⇒ Object
readonly
Returns the value of attribute caller_context.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#query_options ⇒ Object
readonly
Returns the value of attribute query_options.
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(caller_context, base_url:, endpoint:, query_options:) ⇒ ContextWrapper
constructor
A new instance of ContextWrapper.
- #od_full_url(path, anchor: nil, **query_params) ⇒ Object
Constructor Details
#initialize(caller_context, base_url:, endpoint:, query_options:) ⇒ ContextWrapper
Returns a new instance of ContextWrapper.
8 9 10 11 12 13 |
# File 'lib/odata_duty/context_wrapper.rb', line 8 def initialize(caller_context, base_url:, endpoint:, query_options:) super(caller_context) @base_url = base_url.chomp('/') @endpoint = endpoint @query_options = .to_h end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/odata_duty/context_wrapper.rb', line 6 def base_url @base_url end |
#caller_context ⇒ Object (readonly)
Returns the value of attribute caller_context.
6 7 8 |
# File 'lib/odata_duty/context_wrapper.rb', line 6 def caller_context @caller_context end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/odata_duty/context_wrapper.rb', line 6 def endpoint @endpoint end |
#query_options ⇒ Object (readonly)
Returns the value of attribute query_options.
6 7 8 |
# File 'lib/odata_duty/context_wrapper.rb', line 6 def @query_options end |
Instance Method Details
#current ⇒ Object
22 23 24 |
# File 'lib/odata_duty/context_wrapper.rb', line 22 def current @current ||= {} end |
#od_full_url(path, anchor: nil, **query_params) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/odata_duty/context_wrapper.rb', line 15 def od_full_url(path, anchor: nil, **query_params) URI.parse([base_url, path].join('/')).tap do |uri| uri.query = URI.encode_www_form(query_params) if query_params.any? uri.fragment = anchor end.to_str end |