Class: Docman::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/docman/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
# File 'lib/docman/config.rb', line 10

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

Instance Attribute Details

#unmutable_configObject (readonly)

Returns the value of attribute unmutable_config.



8
9
10
# File 'lib/docman/config.rb', line 8

def unmutable_config
  @unmutable_config
end

Instance Method Details

#assign_to_selfObject



16
17
18
19
20
21
# File 'lib/docman/config.rb', line 16

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

#config_hashObject



29
30
31
# File 'lib/docman/config.rb', line 29

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

#merge_config_from_file(file) ⇒ Object



23
24
25
26
27
# File 'lib/docman/config.rb', line 23

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