Class: Octofart::Client
- Inherits:
-
Object
- Object
- Octofart::Client
- Defined in:
- lib/octofart/client.rb
Constant Summary collapse
- DEFAULT_ARGS =
{ connection_options: { request: { open_timeout: 2, timeout: 5, } } }.freeze
- RETRYABLE_ERRORS =
[ Faraday::ConnectionFailed, Faraday::TimeoutError, Octokit::InternalServerError, Octokit::BadGateway ].freeze
Instance Method Summary collapse
-
#initialize(max_retries: 1, **args) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(max_retries: 1, **args) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 |
# File 'lib/octofart/client.rb', line 20 def initialize(max_retries: 1, **args) octokit_args = DEFAULT_ARGS.merge(args) @max_retries = max_retries || 1 @client = Octokit::Client.new(**octokit_args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/octofart/client.rb', line 27 def method_missing(method_name, *args, &block) retry_connection_failures do if @client.respond_to?(method_name) mutatable_args = args.map(&:dup) @client.public_send(method_name, *mutatable_args, &block) else super end end end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
38 39 40 |
# File 'lib/octofart/client.rb', line 38 def respond_to_missing?(method_name, include_private = false) @client.respond_to?(method_name) || super end |