mashed 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mashed/mash.rb +1 -1
- data/lib/mashed/stringy_hash.rb +4 -1
- data/lib/mashed/version.rb +1 -1
- data/spec/mashed/mash_spec.rb +1 -1
- data/spec/mashed/stringy_hash_spec.rb +2 -2
- metadata +1 -1
data/lib/mashed/mash.rb
CHANGED
data/lib/mashed/stringy_hash.rb
CHANGED
@@ -3,7 +3,10 @@ require 'delegate'
|
|
3
3
|
module Mashed
|
4
4
|
module ExtendHash
|
5
5
|
def stringify
|
6
|
-
StringyHash.new(dup.each_with_object({})
|
6
|
+
StringyHash.new(dup.each_with_object({}) do |(k,v), h|
|
7
|
+
v = v.stringify if v.respond_to?(:stringify)
|
8
|
+
h[k.to_s] = v
|
9
|
+
end)
|
7
10
|
end
|
8
11
|
end
|
9
12
|
|
data/lib/mashed/version.rb
CHANGED
data/spec/mashed/mash_spec.rb
CHANGED
@@ -58,7 +58,7 @@ describe Mashed::Mash do
|
|
58
58
|
let(:nested) { Mashed::Mash.new(inside: { of: 'you' }) }
|
59
59
|
let(:hash) { nested.to_hash }
|
60
60
|
it { expect(hash["inside"]).to be_a(Hash) }
|
61
|
-
it { expect(
|
61
|
+
it { expect(hash["inside"]["of"]).to eq('you') }
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "query methods should return booleans" do
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Mashed::StringyHash do
|
4
|
-
let(:hash) {{ a: 1, b: 2, c: 3 }}
|
4
|
+
let(:hash) {{ a: 1, b: 2, c: { three: 3 }}}
|
5
5
|
|
6
6
|
describe "#stringify" do
|
7
|
-
it { expect(hash.stringify).to eq("a" => 1, "b" => 2, "c" => 3) }
|
7
|
+
it { expect(hash.stringify).to eq("a" => 1, "b" => 2, "c" => { "three" => 3 }) }
|
8
8
|
end
|
9
9
|
end
|