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