mashed 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,10 @@ module Mashed
12
12
  singleton_method_removed(symbol)
13
13
  end
14
14
 
15
- def object_id
16
- __id__
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
@@ -1,3 +1,3 @@
1
1
  module Mashed
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -33,6 +33,11 @@ describe Mashed::Mash do
33
33
  }
34
34
  end
35
35
 
36
+ describe "#method_missing=" do
37
+ before { mash.test = "TEST" }
38
+ it { expect(mash.test).to eq("TEST") }
39
+ end
40
+
36
41
  describe "#methods" do
37
42
  it { expect(mash.methods).to include(:__send__) }
38
43
  end
@@ -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.0
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: 2013-12-18 00:00:00.000000000 Z
12
+ date: 2014-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler