field_mapper 0.2.5 → 0.2.6
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 +4 -4
- data/lib/field_mapper/custom/field.rb +1 -1
- data/lib/field_mapper/standard/plat.rb +3 -1
- data/lib/field_mapper/version.rb +1 -1
- data/test/standard/plat_test.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec7cbeeb402db9aee10a715b4917c2e95850d7dc
|
4
|
+
data.tar.gz: 6d529f9cbb56f76e1b5276d54c135bb01cb47376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8ad947978936ce3b2d8343298474149ba7c9360aaf5c4a318345872f49e38a8569558f592439bd02c1b4394d5ce939f8737bf5bdad5bfee9d0000e07d71b49
|
7
|
+
data.tar.gz: aff226ac411f068298a2d58cccb4ad66d9e00b81643c345037c02bb03f503e5c041909e5447dd39d7df4c48af6bf46e279c7332b5ef460606c4bf4d562c2496c
|
@@ -103,7 +103,7 @@ module FieldMapper
|
|
103
103
|
instance_variable_set "@#{attr_name(field_name)}", field.cast(value)
|
104
104
|
end
|
105
105
|
|
106
|
-
def to_hash(flatten: false, history: {}, include_meta: true)
|
106
|
+
def to_hash(flatten: false, history: {}, include_meta: true, placeholders: false)
|
107
107
|
history[object_id] = true
|
108
108
|
hash = self.class.fields.values.reduce(HashWithIndifferentAccess.new) do |memo, field|
|
109
109
|
name = field.name
|
@@ -146,6 +146,8 @@ module FieldMapper
|
|
146
146
|
when "Time" then
|
147
147
|
value = value.utc.iso8601
|
148
148
|
end
|
149
|
+
else
|
150
|
+
value = field.placeholder if placeholders
|
149
151
|
end
|
150
152
|
|
151
153
|
memo[name] = value
|
data/lib/field_mapper/version.rb
CHANGED
data/test/standard/plat_test.rb
CHANGED
@@ -64,6 +64,10 @@ module Standard
|
|
64
64
|
assert hash[:letters] == "[\"a\",\"b\"]"
|
65
65
|
end
|
66
66
|
|
67
|
+
test "to_hash with placeholders" do
|
68
|
+
assert @instance.to_hash(placeholders: true)[:name] == "TYPE YOUR NAME"
|
69
|
+
end
|
70
|
+
|
67
71
|
test "parent & children" do
|
68
72
|
parent = Standard::PlatExample.new
|
69
73
|
parent_id = parent.object_id
|