field_mapper 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73a3b9030b81d91ba6892c32aa09ae5349cc840c
4
- data.tar.gz: ac3cffd1c268087695783c11aa5e01ed19a1e155
3
+ metadata.gz: 594d6e1015351ef81696eab1ce80313212559aef
4
+ data.tar.gz: 12b8c1966a7f79fd27e12ec6b6ed71ffb0876f2e
5
5
  SHA512:
6
- metadata.gz: fa8c586e3c5896c067100985b325ebd8ce29d2f710c6d53e109b70b804f165b3a2181df7081274b36dd86b33802f98508f534e4653ff159b7a99688a77a38e11
7
- data.tar.gz: 6e259cf21a400af2a0370d4e8721ebc21b38b38b837df27e944c693c4ceaab9768812edf4bc13d77a474df07e415febeb3b0724cff7e7452818399d9579f0b1b
6
+ metadata.gz: 933897fa0a3a6d48af2ec7de7820dba8f33801d4cc0c01d42ebc6fbc3ff08f5264b48f482b0672b1b92199df75d0117bdb52c57179597d7a6173a7be1410890a
7
+ data.tar.gz: 9b69b2596b7e1edd9868a7bd8fe34d8f34204b4ca0b73e501840de9cd8bf183b24e1a9f240148f5c62b42a25f67917daec77f643b298ac80a42991090e23b3c6
@@ -67,6 +67,25 @@ module FieldMapper
67
67
  end
68
68
  end
69
69
 
70
+ def inspect
71
+ "#{name} #{new.snapshot.inspect}"
72
+ end
73
+
74
+ def symbolize_hash(hash)
75
+ hash.reduce({}) do |memo, pair|
76
+ key = pair.first.intern
77
+ value = pair.last
78
+ value = symbolize_hash(value) if value.is_a?(Hash)
79
+ if value.is_a?(Array)
80
+ value = value.map do |val|
81
+ val = symbolize_hash(val) if val.is_a?(Hash)
82
+ end
83
+ end
84
+ memo[key] = value
85
+ memo
86
+ end
87
+ end
88
+
70
89
  end
71
90
 
72
91
  attr_reader :node_id
@@ -77,6 +96,10 @@ module FieldMapper
77
96
  assign_params params
78
97
  end
79
98
 
99
+ def inspect
100
+ "#<#{self.class.name}:0x00#{object_id.to_s(16)} #{snapshot.inspect}>"
101
+ end
102
+
80
103
  def scope
81
104
  @scope ||= begin
82
105
  scope_name = self.class.name.split("::")[0..-2].join("::")
@@ -174,6 +197,10 @@ module FieldMapper
174
197
  HashWithIndifferentAccess.new(hash)
175
198
  end
176
199
 
200
+ def snapshot
201
+ self.class.symbolize_hash(to_hash(include_meta: false))
202
+ end
203
+
177
204
  def cache_key
178
205
  self.class.name + "-" + Digest::MD5.hexdigest(to_hash.to_s)
179
206
  end
@@ -1,3 +1,3 @@
1
1
  module FieldMapper
2
- VERSION = "0.3.10"
2
+ VERSION = "0.3.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: field_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport