Implement basic rendering

Woo actioncontroller
This commit is contained in:
Steve Klabnik
2014-07-09 17:52:31 -04:00
parent 45803f1aa1
commit 970b542549
6 changed files with 102 additions and 2 deletions

View File

@@ -19,6 +19,28 @@ module ActiveModel
end
end
if RUBY_VERSION >= '2.0'
def self.serializer_for(resource)
if resource.respond_to?(:to_ary)
ArraySerializer
else
begin
Object.const_get "#{resource.class.name}Serializer"
rescue NameError
nil
end
end
end
else
def self.serializer_for(resource)
if resource.respond_to?(:to_ary)
ArraySerializer
else
"#{resource.class.name}Serializer".safe_constantize
end
end
end
attr_accessor :object
def initialize(object)