Sha256: 7eb41aed9a12590132f3d91ece70f5b06eece3fd7918c830e6d224f073644bfe

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

module Billplz
  class Configuration
    attr_accessor :api_key,:api_url, :http_timeout, :mode

    def initialize(options={})
      @http_timeout = 30
      @mode         = 'live'
    end

    def options
      hash = Hash.new
      %w[api_key api_url http_timeout mode].map{|key| hash[key.to_sym] = send(key) }
      hash
    end
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configuration=(args)
    @configuration ||= Configuration.new
    args.each do |arg|
      @configuration.send("#{arg.first}=", arg.last)
    end
  end

  def self.options
    @configuration.options
  end

  def self.configure
    yield configuration
  end

  def self.reset
    @configuration = nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
billplz-api-0.2.0 lib/billplz/configuration.rb
billplz-api-0.1.0 lib/billplz/configuration.rb