superseeder 0.9.8.1 → 0.9.8.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e902a78787be45381de73ab13635869ee17435c6
4
- data.tar.gz: c081155101097465d1836a5d1cbd55ce86dbbad6
3
+ metadata.gz: 1cb740903ff215700321a61e67f30b1003ae6503
4
+ data.tar.gz: 12f91256303b6fe7ed55d1ff2633b42dd74a0018
5
5
  SHA512:
6
- metadata.gz: cec743349edff5b05ef930364c7a45649b7075d582bce5521e6aaf5afce0c30c71694d3f0fb65029b0bca7a821bb943c78493322eb5077682d812897f29b6085
7
- data.tar.gz: 75d570e6d67d08cf04c74894b1ea753fdc8f75f3156b6405593fead222b5c448383bf95b6e9e9563cab56627b02501e70d4e4b69403ef81f0a5d8ccc7e3a6f30
6
+ metadata.gz: 152314ea7ad7a866c9fdab7009267ddd4814cc63e701a361ea7a533e13d92ef0186497a5ab06b3027ba1794b04ea2ad1d5eebada722518a3704034ac21b46d28
7
+ data.tar.gz: 256fd0f0eebf95b846d495d55b2162fab7ce8db531a6715d1ab3e1b75430027405b50d6c6a0766f56d50cc57d5650ce9fdd308bb94c72704c09a843415fe138f
@@ -11,7 +11,7 @@ module Superseeder
11
11
  def each_field(row)
12
12
  self.instance.attributes.each do |field, val|
13
13
  next unless row.key? field
14
- yield field, false #self.is_array_field?(options) TODO inquiry
14
+ yield field, false, false #self.is_array_field?(options) TODO inquiry
15
15
  end
16
16
  end
17
17
 
@@ -21,6 +21,10 @@ module Superseeder
21
21
  options.type == Array
22
22
  end
23
23
 
24
+ def is_hash_field?(options)
25
+ options.type == Hash
26
+ end
27
+
24
28
  def is_array_relation?(reflection)
25
29
  [::ActiveRecord::Reflection::HasManyReflection,
26
30
  ::ActiveRecord::Reflection::HasAndBelongsToManyReflection].any?{ |c| reflection.kind_of? c }
@@ -10,7 +10,7 @@ module Superseeder
10
10
 
11
11
  def each_field(row)
12
12
  self.instance.fields.select{ |f, o| row.key? o.options[:as] || f }.each do |field, options|
13
- yield options.options[:as] || field, self.is_array_field?(options)
13
+ yield options.options[:as] || field, self.is_array_field?(options), self.is_hash_field?(options)
14
14
  end
15
15
  end
16
16
 
@@ -20,6 +20,10 @@ module Superseeder
20
20
  options.type == Array
21
21
  end
22
22
 
23
+ def is_hash_field?(options)
24
+ options.type == Hash
25
+ end
26
+
23
27
  def is_array_relation?(options)
24
28
  [::Mongoid::Relations::Referenced::Many,
25
29
  ::Mongoid::Relations::Embedded::Many,
@@ -74,9 +74,11 @@ module Superseeder
74
74
  end
75
75
 
76
76
  # Set fields
77
- adapter.each_field(row) do |name, is_array|
77
+ adapter.each_field(row) do |name, is_array, is_hash|
78
78
  val = if is_array
79
79
  row[name].try(:split, many_sep)
80
+ elsif is_hash
81
+ eval row[name] if row[name]
80
82
  else
81
83
  row[name]
82
84
  end
@@ -1,3 +1,3 @@
1
1
  module Superseeder
2
- VERSION = '0.9.8.1'
2
+ VERSION = '0.9.8.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superseeder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8.1
4
+ version: 0.9.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Milla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails