Class: Docman::Config
- Inherits:
-
Hash
- Object
- Hash
- Docman::Config
- Defined in:
- lib/docman/config.rb
Instance Attribute Summary collapse
-
#unmutable_config ⇒ Object
readonly
Returns the value of attribute unmutable_config.
Instance Method Summary collapse
- #assign_to_self ⇒ Object
- #config_hash ⇒ Object
-
#initialize(file) ⇒ Config
constructor
A new instance of Config.
- #merge_config_from_file(file) ⇒ Object
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_config ⇒ Object (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_self ⇒ Object
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_hash ⇒ Object
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 |