serialize_variants 0.1.2 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/serialize_variants.rb +20 -2
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/serialize_variants.rb
CHANGED
@@ -23,12 +23,30 @@ module SerializeVariants
|
|
23
23
|
force = options[:force] || {}
|
24
24
|
|
25
25
|
if options[:variant]
|
26
|
-
super((self.class.serialize_variant(options[:variant]) || {}).merge(force))
|
26
|
+
res = super((self.class.serialize_variant(options[:variant]) || {}).merge(options).merge(force))
|
27
27
|
else
|
28
|
-
super(options)
|
28
|
+
res = super(options)
|
29
|
+
end
|
30
|
+
if options[:delete_blank]
|
31
|
+
SerializeVariants::delete_blank(res)
|
32
|
+
else
|
33
|
+
res
|
29
34
|
end
|
30
35
|
end
|
36
|
+
|
37
|
+
end
|
38
|
+
def self.delete_blank(hash)
|
39
|
+
hash.delete_if do |k, v|
|
40
|
+
v.compact! if v.respond_to?(:compact!)
|
41
|
+
next true if v == nil
|
42
|
+
next true if v.respond_to?(:empty?) && v.empty?
|
43
|
+
next true if v.instance_of?(Hash) && SerializeVariants::delete_blank(v).empty?
|
44
|
+
next false
|
45
|
+
end
|
46
|
+
hash
|
31
47
|
end
|
32
48
|
end
|
33
49
|
|
34
50
|
::ActiveRecord::Base.send :include, SerializeVariants::Variants
|
51
|
+
|
52
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: serialize_variants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nicolas Goy
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-23 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|