Class: Footrest::Client
- Inherits:
-
Object
- Object
- Footrest::Client
- Includes:
- Connection, Request
- Defined in:
- lib/footrest/client.rb
Constant Summary collapse
- CONFIG_ACCESSORS =
Well-known options surfaced as reader/writer methods (e.g. client.token). Any other option remains reachable through #config (e.g. config).
%i[token prefix logging].freeze
Instance Method Summary collapse
-
#config ⇒ Object
Per-instance options bag.
- #connection(&block) ⇒ Object
- #fullpath(path) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
Methods included from Request
#delete, #get, #patch, #post, #put, #request, #request_with_params_in_body, #request_with_params_in_url
Methods included from Connection
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 |
# File 'lib/footrest/client.rb', line 14 def initialize(={}, &block) config.merge!() yield self if block_given? set_connection(config) end |
Instance Method Details
#config ⇒ Object
Per-instance options bag. ActiveSupport::OrderedOptions supports both hash-style (config) and method-style (config.token) access, the same surface ActiveSupport::Configurable’s config object provided. This replaces ‘include ActiveSupport::Configurable`, which activesupport deprecates in 8.1 and removes in 8.2.
25 26 27 |
# File 'lib/footrest/client.rb', line 25 def config @config ||= ActiveSupport::OrderedOptions.new end |
#connection(&block) ⇒ Object
34 35 36 37 38 |
# File 'lib/footrest/client.rb', line 34 def connection(&block) @connection.tap do |conn| yield conn if block_given? end end |
#fullpath(path) ⇒ Object
40 41 42 43 |
# File 'lib/footrest/client.rb', line 40 def fullpath(path) return path if path =~ /^https?:/i prefix ? join(prefix, path) : path end |