class Imperium::Client
Constants
- UNIVERSAL_API_OPTIONS
Options that are allowed for all API endpoints
Attributes
path_prefix[RW]
subclasses[R]
config[R]
Public Class Methods
default_client()
click to toggle source
# File lib/imperium/client.rb, line 13 def default_client @default_client ||= new(Imperium.configuration) end
inherited(subclass)
click to toggle source
# File lib/imperium/client.rb, line 23 def self.inherited(subclass) @subclasses << subclass end
new(config)
click to toggle source
# File lib/imperium/client.rb, line 33 def initialize(config) @config = config @http_client = Imperium::HTTPClient.new(config) end
reset_default_client()
click to toggle source
# File lib/imperium/client.rb, line 17 def reset_default_client @default_client = nil end
reset_default_clients()
click to toggle source
# File lib/imperium/client.rb, line 27 def self.reset_default_clients @subclasses.each(&:reset_default_client) end
Public Instance Methods
hashify_options(options_array)
click to toggle source
# File lib/imperium/client.rb, line 55 def hashify_options(options_array) options_array.inject({}) { |hash, value| value.is_a?(Hash) ? hash.merge(value) : hash.merge(value.to_sym => nil) } end
path_prefix()
click to toggle source
# File lib/imperium/client.rb, line 38 def path_prefix self.class.path_prefix end
Private Instance Methods
extract_query_params(full_options, allowed_params: :all)
click to toggle source
# File lib/imperium/client.rb, line 44 def extract_query_params(full_options, allowed_params: :all) if full_options.key?(:consistent) && full_options.key?(:stale) raise InvalidConsistencySpecification, 'Both consistency modes (consistent, stale) supplied, this is not allowed by the HTTP API' end allowed_params == :all ? full_options : full_options.select { |k, _| allowed_params.include?(k.to_sym) || UNIVERSAL_API_OPTIONS.include?(k.to_sym) } end
prefix_path(main_path, prefix = self.path_prefix)
click to toggle source
# File lib/imperium/client.rb, line 61 def prefix_path(main_path, prefix = self.path_prefix) "#{prefix}/#{main_path}" end