Merge branch 'ouvrages-exclude_nil_links'

This commit is contained in:
Benjamin Fleischer
2016-06-09 02:51:26 -05:00
4 changed files with 5 additions and 2 deletions

View File

@@ -474,7 +474,8 @@ module ActiveModelSerializers
# }.reject! {|_,v| v.nil? }
def links_for(serializer)
serializer._links.each_with_object({}) do |(name, value), hash|
hash[name] = Link.new(serializer, value).as_json
result = Link.new(serializer, value).as_json
hash[name] = result if result
end
end

View File

@@ -71,7 +71,7 @@ module ActiveModelSerializers
hash[:href] = @href if defined?(@href)
hash[:meta] = @meta if defined?(@meta)
hash
hash.any? ? hash : nil
end
protected