Sha256: 5581b1b3d91c175d0bd450d83f5ea9cdbf176171540049b86e4805faca91e203

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Strava
  module Web
    class Client
      include Strava::Web::Connection
      include Strava::Web::Request

      attr_accessor(*Config::ATTRIBUTES)

      def initialize(options = {})
        Strava::Web::Config::ATTRIBUTES.each do |key|
          send("#{key}=", options[key] || Strava::Web.config.send(key))
        end
        @logger ||= Strava::Logger.logger
      end

      def endpoint
        raise NotImplementedError
      end

      class << self
        def configure
          block_given? ? yield(Config) : Config
        end

        def config
          Config
        end
      end

      def parse_args(id_or_options, options = {})
        if id_or_options.is_a?(Hash)
          throw ArgumentError.new('Required argument :id missing') if id_or_options[:id].nil?
          [id_or_options[:id], id_or_options.except(:id)]
        else
          throw ArgumentError.new('Required argument :id missing') if id_or_options.nil?
          [id_or_options, options]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
strava-ruby-client-2.2.0 lib/strava/web/client.rb
strava-ruby-client-2.1.0 lib/strava/web/client.rb
strava-ruby-client-2.0.0 lib/strava/web/client.rb
strava-ruby-client-1.1.0 lib/strava/web/client.rb
strava-ruby-client-1.0.1 lib/strava/web/client.rb
strava-ruby-client-1.0.0 lib/strava/web/client.rb