Implement included and id and type as per spec

This commit is contained in:
Mateo Murphy
2015-03-20 16:04:33 -04:00
parent d82c599c68
commit 33f3a88ba0
12 changed files with 203 additions and 130 deletions

View File

@@ -164,6 +164,14 @@ module ActiveModel
end
end
def id
object.id if object
end
def type
object.class.to_s.demodulize.underscore.pluralize
end
def attributes(options = {})
attributes =
if options[:fields]
@@ -172,6 +180,8 @@ module ActiveModel
self.class._attributes.dup
end
attributes += options[:required_fields] if options[:required_fields]
attributes.each_with_object({}) do |name, hash|
hash[name] = send(name)
end