class Octofart::Client

Constants

DEFAULT_ARGS
RETRYABLE_ERRORS

Public Class Methods

new(max_retries: 1, **args) click to toggle source
# 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

Public Instance Methods

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# 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
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/octofart/client.rb, line 38
def respond_to_missing?(method_name, include_private = false)
  @client.respond_to?(method_name) || super
end

Private Instance Methods

retry_connection_failures() { || ... } click to toggle source
# File lib/octofart/client.rb, line 44
def retry_connection_failures
  retry_attempt = 0

  begin
    yield
  rescue *RETRYABLE_ERRORS
    retry_attempt += 1
    retry_attempt <= @max_retries ? retry : raise
  end
end