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 +4 -4
- data/lib/form_core/coder.rb +8 -0
- data/lib/form_core/coders/hash_coder.rb +1 -1
- data/lib/form_core/coders/yaml_coder.rb +1 -1
- data/lib/form_core/version.rb +1 -1
- data/lib/form_core/virtual_model.rb +5 -6
- 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: eb0a7243fa2c84f2517ed634654590a3969b1444
|
4
|
+
data.tar.gz: 1afaae3ec02223810f1286f9dc7102be4e537e6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dedc51b8213ed6cd2311949f320ffeff7564f9fb69980e4216d281a40b2695939f1dd49f9ed4216b9c9901b68abcf211c2553fbf859fdfd07142c4a29d6de0a
|
7
|
+
data.tar.gz: d1c00a4578414c526f277eba176b73d6136905546b923b069f1f59ea3c6b68d6953cc4d97842d8ac1f5f5d3acdc3e64960a249894918f3fb5ab47fd1fad191ed
|
data/lib/form_core/coder.rb
CHANGED
@@ -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
|
data/lib/form_core/version.rb
CHANGED
@@ -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
|