mbleigh-mash 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.txt +2 -1
- data/lib/mash.rb +5 -5
- data/mash.gemspec +1 -1
- data/spec/mash_spec.rb +7 -0
- metadata +1 -1
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -46,7 +46,8 @@ http://mbleigh.lighthouseapp.com/projects/10112-mash
|
|
46
46
|
|
47
47
|
== LICENSE:
|
48
48
|
|
49
|
-
Copyright (c) 2008 Michael Bleigh
|
49
|
+
Copyright (c) 2008 Michael Bleigh (http://mbleigh.com/)
|
50
|
+
and Intridea Inc. (http://intridea.com/), released under the MIT license
|
50
51
|
|
51
52
|
Permission is hereby granted, free of charge, to any person obtaining
|
52
53
|
a copy of this software and associated documentation files (the
|
data/lib/mash.rb
CHANGED
@@ -128,14 +128,14 @@ class Mash < Hash
|
|
128
128
|
# Recursively merges this mash with the passed
|
129
129
|
# in hash, merging each hash in the hierarchy.
|
130
130
|
def deep_update(other_hash)
|
131
|
-
|
132
|
-
|
131
|
+
other_hash = other_hash.stringify_keys unless other_hash.is_a?(Mash)
|
132
|
+
other_hash.each_pair do |k,v|
|
133
133
|
k = convert_key(k)
|
134
134
|
self[k] = self[k].to_mash if self[k].is_a?(Hash) unless self[k].is_a?(Mash)
|
135
|
-
if self[k].is_a?(Hash) &&
|
136
|
-
self[k].deep_merge!(
|
135
|
+
if self[k].is_a?(Hash) && other_hash[k].is_a?(Hash)
|
136
|
+
self[k].deep_merge!(other_hash[k])
|
137
137
|
else
|
138
|
-
self.send(k + "=", convert_value(
|
138
|
+
self.send(k + "=", convert_value(other_hash[k]))
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
data/mash.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "mash"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.5"
|
4
4
|
s.date = "2008-04-26"
|
5
5
|
s.summary = "An extended Hash that gives simple pseudo-object functionality that can be built from hashes and easily extended"
|
6
6
|
s.email = "michael@intridea.com"
|
data/spec/mash_spec.rb
CHANGED
@@ -88,6 +88,13 @@ describe Mash do
|
|
88
88
|
converted.a.first.b.should == 12
|
89
89
|
converted.a.last.should == 23
|
90
90
|
end
|
91
|
+
|
92
|
+
it "should convert an existing Mash into a Mash" do
|
93
|
+
initial = Mash.new(:name => 'randy')
|
94
|
+
copy = Mash.new(initial)
|
95
|
+
initial.name.should == copy.name
|
96
|
+
end
|
97
|
+
|
91
98
|
end
|
92
99
|
end
|
93
100
|
|