Sha256: 5e6f3d366658d4fe36819c5d5f320bfe64851d955d3542aea2b09e1aa854dac3
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module Teachable module Jg module Configuration VALID_CONNECTION_KEYS = [:endpoint, :user_agent, :method].freeze VALID_OPTIONS_KEYS = [:api_key, :format].freeze VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS DEFAULT_ENDPOINT = 'http://teachable.dev/api' DEFAULT_METHOD = :get DEFAULT_USER_AGENT = "Teachable API Ruby Gem #{Teachable::Jg::VERSION}".freeze DEFAULT_API_KEY = nil DEFAULT_FORMAT = :json # Build accessor methods for every config options so we can do this, for example: # Teachable::Jg.format = :xml attr_accessor *VALID_CONFIG_KEYS # Make sure we have the default values set when we get 'extended' def self.extended(base) base.reset end def options Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ] end def reset self.endpoint = DEFAULT_ENDPOINT self.method = DEFAULT_METHOD self.user_agent = DEFAULT_USER_AGENT self.api_key = DEFAULT_API_KEY self.format = DEFAULT_FORMAT end def configure yield self end end # Configuration end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
teachable-jg-0.0.2 | lib/teachable/jg/configuration.rb |
teachable-jg-0.0.1 | lib/teachable/jg/configuration.rb |