Sha256: 2b8421bb466dcf2b263916611794b456b1c3f1160e8dc5e1fb2b4488bf6b09c8

Contents?: true

Size: 1.17 KB

Versions: 11

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  => false,
        :@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

11 entries across 11 versions & 1 rubygems

Version Path
docdata-0.2.3 lib/docdata/config.rb
docdata-0.2.2 lib/docdata/config.rb
docdata-0.2.1 lib/docdata/config.rb
docdata-0.2.0 lib/docdata/config.rb
docdata-0.1.8 lib/docdata/config.rb
docdata-0.1.7 lib/docdata/config.rb
docdata-0.1.6 lib/docdata/config.rb
docdata-0.1.5 lib/docdata/config.rb
docdata-0.1.4 lib/docdata/config.rb
docdata-0.1.2 lib/docdata/config.rb
docdata-0.1.1 lib/docdata/config.rb