mashed 0.3.0 → 0.4.0

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.
data/lib/mashed/mash.rb CHANGED
@@ -12,6 +12,10 @@ module Mashed
12
12
  singleton_method_removed(symbol)
13
13
  end
14
14
 
15
+ def object_id
16
+ __id__
17
+ end
18
+
15
19
  def to_hash
16
20
  @hash.to_hash
17
21
  end
@@ -81,6 +85,14 @@ module Mashed
81
85
  end
82
86
  alias to_s inspect
83
87
 
88
+ def pretty_inspect
89
+ inspect
90
+ end
91
+
92
+ def pretty_print
93
+ inspect
94
+ end
95
+
84
96
  private
85
97
 
86
98
  def wrap_up(thing)
@@ -98,5 +110,17 @@ module Mashed
98
110
  thing
99
111
  end
100
112
  end
113
+
114
+ def unwrap(thing)
115
+ if thing.respond_to?(:to_hash)
116
+ thing.to_hash.each_with_object({}) do |(key, value), hash|
117
+ hash[key] = unwrap(value)
118
+ end
119
+ elsif thing.respond_to?(:to_ary)
120
+ thing.map { |t| unwrap(t) }
121
+ else
122
+ thing
123
+ end
124
+ end
101
125
  end
102
126
  end
@@ -1,3 +1,3 @@
1
1
  module Mashed
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -54,6 +54,13 @@ describe Mashed::Mash do
54
54
  it { expect(nested.inside.of).to eq('you') }
55
55
  end
56
56
 
57
+ describe "nested hashed #to_hash" do
58
+ let(:nested) { Mashed::Mash.new(inside: { of: 'you' }) }
59
+ let(:hash) { nested.to_hash }
60
+ it { expect(hash["inside"]).to be_a(Hash) }
61
+ it { expect(nested["inside"]["of"]).to eq('you') }
62
+ end
63
+
57
64
  describe "query methods should return booleans" do
58
65
  let(:grumpy) { Mashed::Mash.new(yes: "hooray", no: nil) }
59
66
  it { expect(grumpy.yes?).to be(true) }
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.3.0
4
+ version: 0.4.0
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-11-07 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler