field_mapper 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43226c49e641e6c7534c9aa0656857af80d4e8e0
4
- data.tar.gz: 9169cce64f196bbd5a8ecad35ef5c9fdf57bb34c
3
+ metadata.gz: ec7cbeeb402db9aee10a715b4917c2e95850d7dc
4
+ data.tar.gz: 6d529f9cbb56f76e1b5276d54c135bb01cb47376
5
5
  SHA512:
6
- metadata.gz: b2b5fb6da267576062469504cdf7c93fc07d07a1d26912f5431f89648a16106328a89958d8d43b75fa316152848d74c190576a921bd72fd6a8c5b04ab478cc64
7
- data.tar.gz: 0e78802579e987fafab953d42b31e114b9372f446c97413d08189916b85c7392a6abd229e5d14bb0799e8c3a6bae6968c6404c228c1baf2e6dad9787f67eae82
6
+ metadata.gz: 3e8ad947978936ce3b2d8343298474149ba7c9360aaf5c4a318345872f49e38a8569558f592439bd02c1b4394d5ce939f8737bf5bdad5bfee9d0000e07d71b49
7
+ data.tar.gz: aff226ac411f068298a2d58cccb4ad66d9e00b81643c345037c02bb03f503e5c041909e5447dd39d7df4c48af6bf46e279c7332b5ef460606c4bf4d562c2496c
@@ -46,7 +46,7 @@ module FieldMapper
46
46
  attr_writer :placeholder
47
47
 
48
48
  def placeholder
49
- @placeholder || standard_field.placeholder
49
+ @placeholder || (standard_field && standard_field.placeholder)
50
50
  end
51
51
 
52
52
  def value(value, standard: nil, priority: nil)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FieldMapper
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: field_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins