Sha256: fb51177717410257fb128c0881d592c4fa915328ef037514c7400dceaa4dc96b

Contents?: true

Size: 642 Bytes

Versions: 63

Compression:

Stored size: 642 Bytes

Contents

require 'singleton'
require 'hash_deep_merge'
require 'digest/md5'

module Docman
  class Config < Hash

    attr_reader :unmutable_config

    def initialize(file)
      super
      @config = YAML::load_file(file)
      assign_to_self
    end

    def assign_to_self
      @config.each_pair do |k, v|
        self[k] = v
      end
      @unmutable_config = Marshal::load(Marshal.dump(@config))
    end

    def merge_config_from_file(file)
      config = YAML::load_file(file)
      @config.deep_merge(config)
      assign_to_self
    end

    def config_hash
      Digest::MD5.hexdigest(Marshal::dump(@unmutable_config))
    end

  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
docman-0.0.16 lib/docman/config.rb
docman-0.0.15 lib/docman/config.rb
docman-0.0.14 lib/docman/config.rb