@@ -12,7 +12,6 @@ module SerializationCore
1212 included do
1313 class << self
1414 attr_accessor :attributes_to_serialize ,
15- :optional_attributes_to_serialize ,
1615 :relationships_to_serialize ,
1716 :cachable_relationships_to_serialize ,
1817 :uncachable_relationships_to_serialize ,
@@ -74,21 +73,9 @@ def links_hash(record, params = {})
7473 end
7574
7675 def attributes_hash ( record , params = { } )
77- attributes = attributes_to_serialize . each_with_object ( { } ) do |( key , method ) , attr_hash |
78- attr_hash [ key ] = if method . is_a? ( Proc )
79- method . arity == 1 ? method . call ( record ) : method . call ( record , params )
80- else
81- record . public_send ( method )
82- end
76+ attributes_to_serialize . each_with_object ( { } ) do |( key , attribute ) , attr_hash |
77+ attribute . serialize ( record , params , attr_hash )
8378 end
84-
85- self . optional_attributes_to_serialize = { } if self . optional_attributes_to_serialize . nil?
86- optional_attributes_to_serialize . each do |key , details |
87- method_name , check_proc = details
88- attributes [ key ] = record . send ( method_name ) if check_proc . call ( record , params )
89- end
90-
91- attributes
9279 end
9380
9481 def relationships_hash ( record , relationships = nil , params = { } )
0 commit comments