Class: DotHash::Loader
- Inherits:
-
Object
- Object
- DotHash::Loader
- Defined in:
- lib/dot_hash/loader.rb
Instance Attribute Summary collapse
-
#hashes ⇒ Object
readonly
Returns the value of attribute hashes.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(*hashes) ⇒ Loader
constructor
A new instance of Loader.
- #merge_hashes(h1, h2) ⇒ Object
- #properties ⇒ Object
Constructor Details
#initialize(*hashes) ⇒ Loader
Returns a new instance of Loader.
5 6 7 |
# File 'lib/dot_hash/loader.rb', line 5 def initialize *hashes @hashes = hashes end |
Instance Attribute Details
#hashes ⇒ Object (readonly)
Returns the value of attribute hashes.
3 4 5 |
# File 'lib/dot_hash/loader.rb', line 3 def hashes @hashes end |
Instance Method Details
#hash ⇒ Object
9 10 11 12 13 |
# File 'lib/dot_hash/loader.rb', line 9 def hash hashes.inject({}) do |hash, arg| merge_hashes hash, get_hash_from(arg) end end |
#merge_hashes(h1, h2) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dot_hash/loader.rb', line 19 def merge_hashes(h1, h2) return h1 unless h2 return h2 unless h1 h2.each do |key, value| h1[key] = value.is_a?(Hash) ? merge_hashes(h1[key], value) : value end h1 end |
#properties ⇒ Object
15 16 17 |
# File 'lib/dot_hash/loader.rb', line 15 def properties Properties.new hash end |