lib/alba/serializer.rb in alba-0.11.1 vs lib/alba/serializer.rb in alba-0.12.0
- old
+ new
@@ -21,10 +21,12 @@
def initialize(resource)
@resource = resource
@hash = resource.serializable_hash
@hash = {key.to_sym => @hash} if key
# @hash is either Hash or Array
- @hash.is_a?(Hash) ? @hash.merge!(metadata.to_h) : @hash << metadata
+ unless metadata.empty?
+ @hash.is_a?(Hash) ? @hash.merge!(metadata.to_h) : @hash << metadata
+ end
end
# Use real encoder to actually serialize to JSON
#
# @return [String] JSON string