Sha256: 80648c299e26c1a8fd761f502b34818efcd5cf97933520522eae8e55e65f1841

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

#
# Configuration object for storing some parameters required for making transactions
#
module Docdata::Config
  class << self
    # @return [String] Your DocData username
    # @note The is a required parameter.
    attr_accessor :username
    # @return [String] Your DocData password
    attr_accessor :password
    # @return [Boolean] Test mode switch
    attr_accessor :test_mode
    # @return [String] Base return URL
    attr_accessor :return_url


    # Set's the default value's to nil and false
    # @return [Hash] configuration options
    def init!
      @defaults = {
        :@username   => nil,
        :@password   => nil,
        :@test_mode  => true,
        :@return_url => nil
      }
    end

    # Resets the value's to there previous value (instance_variable)
    # @return [Hash] configuration options
    def reset!
      @defaults.each { |key, value| instance_variable_set(key, value) }
    end

    # Set's the new value's as instance variables
    # @return [Hash] configuration options
    def update!
      @defaults.each do |key, value|
        instance_variable_set(key, value) unless instance_variable_defined?(key)
      end
    end
  end
  init!
  reset!
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docdata-0.1.0 lib/docdata/config.rb
docdata-0.0.5 lib/docdata/config.rb