mashed 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mashed/mash.rb +11 -2
- data/lib/mashed/version.rb +1 -1
- data/spec/mashed/mash_spec.rb +5 -0
- data/spec/mashed/stringy_hash_spec.rb +7 -0
- metadata +2 -2
data/lib/mashed/mash.rb
CHANGED
@@ -12,8 +12,10 @@ module Mashed
|
|
12
12
|
singleton_method_removed(symbol)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
unless defined?(object_id)
|
16
|
+
def object_id
|
17
|
+
__id__
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
def to_hash
|
@@ -57,6 +59,11 @@ module Mashed
|
|
57
59
|
wrap_up @hash[key]
|
58
60
|
end
|
59
61
|
|
62
|
+
def []=(key, value)
|
63
|
+
key = key.to_s
|
64
|
+
@hash[key] = value
|
65
|
+
end
|
66
|
+
|
60
67
|
def keys
|
61
68
|
@hash.keys
|
62
69
|
end
|
@@ -71,6 +78,8 @@ module Mashed
|
|
71
78
|
self[string]
|
72
79
|
elsif string =~ /\?$/
|
73
80
|
!!self[string[0..-2]]
|
81
|
+
elsif string =~ /=$/
|
82
|
+
self[string[0..-2]] = args.first
|
74
83
|
else
|
75
84
|
nil
|
76
85
|
end
|
data/lib/mashed/version.rb
CHANGED
data/spec/mashed/mash_spec.rb
CHANGED
@@ -6,4 +6,11 @@ describe Mashed::StringyHash do
|
|
6
6
|
describe "#stringify" do
|
7
7
|
it { expect(hash.stringify).to eq("a" => 1, "b" => 2, "c" => { "three" => 3 }) }
|
8
8
|
end
|
9
|
+
|
10
|
+
describe "get and set" do
|
11
|
+
let(:s) { hash.stringify }
|
12
|
+
before { s[:a] = "A" }
|
13
|
+
it { expect(s[:a]).to eq("A") }
|
14
|
+
it { expect(s["a"]).to eq("A") }
|
15
|
+
end
|
9
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mashed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|