form_core 0.0.12 → 0.0.13

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: c9dbd63db4f35b9bcf1058b5aab5eddc9767076d
4
- data.tar.gz: 7558de09b058f70d8ae4d241a9aefbc9d840713b
3
+ metadata.gz: eb0a7243fa2c84f2517ed634654590a3969b1444
4
+ data.tar.gz: 1afaae3ec02223810f1286f9dc7102be4e537e6c
5
5
  SHA512:
6
- metadata.gz: 5e1077c3cdd20bcf178e3e925185ee6a6c2e3ad50f6007b5b3121b7474cbe217339466ecebf32f4eb8a1a340d9a0210a0bc99ee563ca717dd1b593d00ad90afd
7
- data.tar.gz: 2e56b171c714e73afc562503bb6d0e5cb1f37c987e40a73852b33aa10b0db6d902ddde1629f634727a227b476d6ae1d1fe0616ba65f1447c70d27e0f06df28ad
6
+ metadata.gz: 6dedc51b8213ed6cd2311949f320ffeff7564f9fb69980e4216d281a40b2695939f1dd49f9ed4216b9c9901b68abcf211c2553fbf859fdfd07142c4a29d6de0a
7
+ data.tar.gz: d1c00a4578414c526f277eba176b73d6136905546b923b069f1f59ea3c6b68d6953cc4d97842d8ac1f5f5d3acdc3e64960a249894918f3fb5ab47fd1fad191ed
@@ -31,5 +31,13 @@ module FormCore
31
31
  object_class.new
32
32
  end
33
33
  end
34
+
35
+ def valid_attribute_names
36
+ object_class.attribute_names + object_class._embeds_reflections.keys
37
+ end
38
+
39
+ def valid_attributes(hash)
40
+ hash.slice(*valid_attribute_names)
41
+ end
34
42
  end
35
43
  end
@@ -13,7 +13,7 @@ module FormCore
13
13
  return new_or_raise_decoding_error
14
14
  end
15
15
 
16
- object_class.new hash.to_h
16
+ object_class.new valid_attributes(hash)
17
17
  end
18
18
  end
19
19
  end
@@ -37,7 +37,7 @@ module FormCore
37
37
  return new_or_raise_decoding_error
38
38
  end
39
39
 
40
- object_class.new decoded
40
+ object_class.new valid_attributes(decoded)
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FormCore
4
- VERSION = "0.0.12"
4
+ VERSION = "0.0.13"
5
5
  end
@@ -23,15 +23,10 @@ module FormCore
23
23
  end
24
24
 
25
25
  def serializable_hash(options = {})
26
- options = (options || {}).reverse_merge include: _embeds_reflections.keys
26
+ options = (options || {}).reverse_merge include: self.class._embeds_reflections.keys
27
27
  super options
28
28
  end
29
29
 
30
- def _embeds_reflections
31
- _reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
32
- end
33
- private :_embeds_reflections
34
-
35
30
  def dump
36
31
  self.class.dump(self)
37
32
  end
@@ -74,6 +69,10 @@ module FormCore
74
69
  attr_list = attribute_types.map { |name, type| "#{name}: #{type.type}" } * ", "
75
70
  "#<VirtualModel:#{name}:#{object_id} #{attr_list}>"
76
71
  end
72
+
73
+ def _embeds_reflections
74
+ _reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
75
+ end
77
76
  end
78
77
  end
79
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl