Sha256: d933d0e484d2b4ba4708eefcbda40e3bbd31e6fa847287ac98ac5325e58b64c1

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

# encoding: utf-8

module Jiralicious
  module Configuration
    VALID_OPTIONS = [:username, :password, :uri, :api_version, :auth_type]
    DEFAULT_USERNAME = nil
    DEFAULT_AUTH_TYPE = :basic
    DEFAULT_PASSWORD = nil
    DEFAULT_URI = nil
    DEFAULT_API_VERSION = "latest"

    def configure
      yield self
    end

    attr_accessor *VALID_OPTIONS

    # Reset when extended into class
    def self.extended(base)
      base.reset
    end

    def options
      VALID_OPTIONS.inject({}) do |option, key|
        option.merge!(key => send(key))
      end
    end

    def reset
      self.username = DEFAULT_USERNAME
      self.password = DEFAULT_PASSWORD
      self.uri = DEFAULT_URI
      self.api_version = DEFAULT_API_VERSION
      self.auth_type = DEFAULT_AUTH_TYPE
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jiralicious-0.1.0 lib/jiralicious/configuration.rb