lib/mutils/serialization/serialization_results.rb in mutils-0.2.36 vs lib/mutils/serialization/serialization_results.rb in mutils-0.2.37
- old
+ new
@@ -17,11 +17,20 @@
{}
end
end
def hashed_result
- [fetch_attributes(self.class.attributes_to_serialize),
+ [fetch_block_attributes(self.class.attributes_to_serialize_blocks),
+ fetch_attributes(self.class.attributes_to_serialize),
hash_relationships(self.class.relationships)].reduce(&:merge)
+ end
+
+ def fetch_block_attributes(attributes)
+ hash = {}
+ attributes&.keys&.each do |key|
+ hash[key] = attributes[key][:block].call(scope, options[:params])
+ end
+ hash
end
def fetch_attributes(attributes)
hash = {}
attributes&.keys&.each do |key|