Sha256: 837e34e9b55a752a9d7f788fd65b3cdafc44f79d796145b71975635043ccf176

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Trell
  module Configurable
    OPTIONS_KEYS = %i(
      login
      password
      application_key
      application_token
      api_endpoint
      web_endpoint
      user_agent
      media_type
    )

    attr_accessor(*OPTIONS_KEYS)

    class << self
      def keys
        @keys ||= OPTIONS_KEYS
      end
    end

    def configure
      yield self
    end

    def reset!
      @login              = ENV['TRELL_LOGIN']
      @password           = ENV['TRELL_PASSWORD']
      @application_key    = ENV['TRELL_APPLICATION_TOKEN']
      @application_secret = ENV['TRELL_APPLICATION_SECRET']
      @api_endpoint       = ENV['TRELL_API_ENDPOINT'] || 'https://api.trello.com/1/'
      @web_endpoint       = ENV['TRELL_WEB_ENDPOINT'] || 'https://trello.com/'
      @user_agent         = "Trell Ruby Gem #{Trell::VERSION}"
      @media_type         = 'application/json'
      self
    end
    alias setup reset!

    private

    def options
      Hash[Trell::Configurable.keys.map { |key|
        [key, instance_variable_get(:"@#{key}")]
      }]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trell-0.0.2 lib/trell/configurable.rb
trell-0.0.1 lib/trell/configurable.rb