5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/jsonapi/consumer/resource/serializer_concern.rb', line 5
def serializable_hash(options={})
@hash = persisted? ? attributes : attributes.except(self.class.primary_key)
self.each_association do |name, association, options|
@hash[:links] ||= {}
if association.respond_to?(:each) or _association_type(name) == :has_many
add_links(name, association, options)
else
add_link(name, association, options)
end
@hash.delete(:links) if remove_links?
end
@hash
end
|