shadow_puppet 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/shadow_puppet/core_ext.rb +24 -0
  2. metadata +2 -1
@@ -0,0 +1,24 @@
1
+ require 'active_support/core_ext/class/attribute_accessors'
2
+ require 'active_support/core_ext/array'
3
+ require 'active_support/inflector'
4
+ require 'active_support/core_ext/hash/indifferent_access'
5
+ require 'active_support/core_ext/class/inheritable_attributes'
6
+ require 'active_support/core_ext/duplicable'
7
+ class Hash #:nodoc:
8
+ include ActiveSupport::CoreExtensions::Hash::IndifferentAccess
9
+
10
+ # Returns a new hash with +self+ and +other_hash+ merged recursively.
11
+ def deep_merge(other_hash)
12
+ self.merge(other_hash) do |key, oldval, newval|
13
+ oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
14
+ newval = newval.to_hash if newval.respond_to?(:to_hash)
15
+ oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
16
+ end
17
+ end
18
+
19
+ # Returns a new hash with +self+ and +other_hash+ merged recursively.
20
+ # Modifies the receiver in place.
21
+ def deep_merge!(other_hash)
22
+ replace(deep_merge(other_hash))
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadow_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Newland
@@ -79,6 +79,7 @@ files:
79
79
  - examples/foo.rb
80
80
  - lib/shadow_puppet.rb
81
81
  - lib/shadow_puppet/manifest.rb
82
+ - lib/shadow_puppet/core_ext.rb
82
83
  has_rdoc: true
83
84
  homepage: http://railsmachine.github.com/shadow_puppet
84
85
  post_install_message: