dynameek 0.3.3 → 0.3.4
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/dynameek/model/dynamo_db.rb +35 -6
- data/lib/dynameek/version.rb +1 -1
- metadata +2 -2
@@ -22,17 +22,46 @@ module Dynameek
|
|
22
22
|
when :datetime
|
23
23
|
value.to_time.to_f
|
24
24
|
when :binary
|
25
|
-
|
26
|
-
value = value.clone
|
27
|
-
value.default = nil
|
28
|
-
end
|
29
|
-
|
25
|
+
dump_safe(value)
|
30
26
|
Marshal.dump(value)
|
31
27
|
else
|
32
28
|
value
|
33
29
|
end
|
34
30
|
end
|
35
|
-
|
31
|
+
StackFrame = Struct.new(:current, :index)
|
32
|
+
|
33
|
+
def dump_safe(obj)
|
34
|
+
return obj if(!obj.is_a?(Hash) && !obj.is_a?(Array))
|
35
|
+
make_safe = lambda do |thing|
|
36
|
+
if thing.is_a?(Hash)
|
37
|
+
#thing.default_proc = nil
|
38
|
+
thing.default = nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
stack = []
|
42
|
+
safe = obj
|
43
|
+
stack.push(StackFrame.new(safe, 0))
|
44
|
+
|
45
|
+
while(current_frame = stack.pop)
|
46
|
+
current = current_frame.current
|
47
|
+
index = current_frame.index
|
48
|
+
obj = current.is_a?(Hash) ? current[current.keys[index]] : current[index]
|
49
|
+
make_safe.call(obj)
|
50
|
+
if index - 1 < current.size
|
51
|
+
# Re-add current enumerable if still elements to check
|
52
|
+
stack.push(StackFrame.new(current, index + 1))
|
53
|
+
end
|
54
|
+
if obj.is_a?(Hash) || obj.is_a?(Array)
|
55
|
+
#If obj is enumerable add to stack
|
56
|
+
stack.push(StackFrame.new(obj, 0))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
safe
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
36
65
|
def index_table_exists?
|
37
66
|
!index_table.nil? && index_table.exists?
|
38
67
|
end
|
data/lib/dynameek/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dynameek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Max Dupenois
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-04-
|
13
|
+
date: 2013-04-15 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|