field_mapper 0.2.7 → 0.2.8

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: 1f4270f21ae469ff50d0da13d86995ca22acbdad
4
- data.tar.gz: 31f5ab8e6f1f11c9f63924f7ecf998b1a46ab1b3
3
+ metadata.gz: 4f009a40a9613eefe1d0a04b110b1e4672c6a79d
4
+ data.tar.gz: d605c6c72f1ccbbec89ca99f0e786d0aa2db5a06
5
5
  SHA512:
6
- metadata.gz: d063074997e312b4c20853bc5744ae4fd2c6823439a6b4aea36a456bbd796dd9192a8dfd2c113b6d9c638b1feab6ae9c3681871414964bb094f2c0fd7669b14a
7
- data.tar.gz: a1e975a827e3e5722f1b92b6594c0105ce04c18534ffd61793ef65315526d1ddf7d99333d5f93400225c85c028ef974fae166233a8444495a60b29698fd54b39
6
+ metadata.gz: 41a60a34ab9b8002a71b13bdcde0053d8cc57da9ed5a833e54638b2ffd3b3ce36de1374ed4d65601ca4665f0a45e8fe6b06c0ae95c9f5d8ebe8ec83f287727f2
7
+ data.tar.gz: 1dbec77a8049c31b2551ecbba1b2745cdb0a5ca3d2fd2104cc702b50ed006f37b141d20295649ca0279d5c490b5f6538a27ae55f5a549a7d9b46ffe106648f27
@@ -44,7 +44,10 @@ module FieldMapper
44
44
  protected
45
45
 
46
46
  def get_raw_standard_value(custom_field, raw_custom_value, standard_instance)
47
- return nil if raw_custom_value.nil?
47
+ if raw_custom_value.nil?
48
+ return [] if custom_field.standard_field.list_with_emtpy_default?
49
+ return nil
50
+ end
48
51
 
49
52
  strategy = custom_field.flip_strategy(:custom_to_standard)
50
53
  custom_flipper = custom_field.custom_flipper?(:custom_to_standard)
@@ -62,7 +65,7 @@ module FieldMapper
62
65
  end
63
66
 
64
67
  if strategy == :find
65
- if custom_field.type.is_a?(FieldMapper::Types::List)
68
+ if custom_field.list?
66
69
  return raw_custom_value.map do |single_raw_custom_value|
67
70
  find_raw_standard_value(custom_field, single_raw_custom_value)
68
71
  end
@@ -37,7 +37,10 @@ module FieldMapper
37
37
  protected
38
38
 
39
39
  def get_raw_custom_value(custom_field, raw_standard_value, custom_instance)
40
- return nil if raw_standard_value.nil?
40
+ if raw_standard_value.nil?
41
+ return [] if custom_field.list_with_emtpy_default?
42
+ return nil
43
+ end
41
44
 
42
45
  strategy = custom_field.flip_strategy(:standard_to_custom)
43
46
  custom_flipper = custom_field.custom_flipper?(:standard_to_custom)
@@ -55,7 +58,7 @@ module FieldMapper
55
58
  end
56
59
 
57
60
  if strategy == :find
58
- if custom_field.type.is_a?(FieldMapper::Types::List)
61
+ if custom_field.list?
59
62
  return raw_standard_value.map do |single_raw_standard_value|
60
63
  find_raw_custom_value(custom_field, single_raw_standard_value)
61
64
  end
@@ -36,6 +36,10 @@ module FieldMapper
36
36
  type.name == "FieldMapper::Types::List"
37
37
  end
38
38
 
39
+ def list_with_emtpy_default?
40
+ list? && default == []
41
+ end
42
+
39
43
  def plat?
40
44
  type.name == "FieldMapper::Types::Plat"
41
45
  end
@@ -1,3 +1,3 @@
1
1
  module FieldMapper
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
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.2.7
4
+ version: 0.2.8
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-04-17 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport