@@ -31,56 +31,21 @@ def serializable_hash(options = nil)
31
31
32
32
names = field_names ( options )
33
33
34
- _serializing do
35
- method_names = Array . wrap ( options [ :methods ] ) . map do |name |
36
- name . to_s if respond_to? ( name )
37
- end . compact
34
+ method_names = Array . wrap ( options [ :methods ] ) . map do |name |
35
+ name . to_s if respond_to? ( name )
36
+ end . compact
38
37
39
- ( names + method_names ) . each do |name |
40
- without_autobuild do
41
- serialize_attribute ( attrs , name , names , options )
42
- end
38
+ ( names + method_names ) . each do |name |
39
+ without_autobuild do
40
+ serialize_attribute ( attrs , name , names , options )
43
41
end
44
- serialize_relations ( attrs , options ) if options [ :include ]
45
42
end
43
+ serialize_relations ( attrs , options ) if options [ :include ]
46
44
attrs
47
45
end
48
46
49
47
private
50
48
51
- # Enter the serialization block.
52
- #
53
- # @api private
54
- #
55
- # @example Begin serialization.
56
- # document._serializing do
57
- # end
58
- #
59
- # @return [ Object ] The result of the yield.
60
- #
61
- # @since 3.0.0
62
- def _serializing
63
- Threaded . begin ( "serialization" )
64
- yield
65
- ensure
66
- Threaded . exit ( "serialization" )
67
- end
68
-
69
- # Are we in a serialization block? We use this to protect multiple
70
- # unnecessary calls to #as_document.
71
- #
72
- # @api private
73
- #
74
- # @example Are we in serialization?
75
- # document._serializing?
76
- #
77
- # @return [ true, false ] If we are serializing.
78
- #
79
- # @since 3.0.0
80
- def _serializing?
81
- Threaded . executing? ( "serialization" )
82
- end
83
-
84
49
# Get the names of all fields that will be serialized.
85
50
#
86
51
# @api private
@@ -92,7 +57,7 @@ def _serializing?
92
57
#
93
58
# @since 3.0.0
94
59
def field_names ( options )
95
- names = ( _serializing? ? attribute_names : as_document . keys + attribute_names ) . uniq . sort
60
+ names = ( as_document . keys + attribute_names ) . uniq . sort
96
61
97
62
only = Array . wrap ( options [ :only ] ) . map ( &:to_s )
98
63
except = Array . wrap ( options [ :except ] ) . map ( &:to_s )
0 commit comments