Simplify association decoration

We don't actually need to reflect on the association because we have
already fetched the associated object - we can just infer the
appropriate decorator from it directly.
This commit is contained in:
Andrew Haines 2012-11-08 13:14:01 +00:00
parent f0a1be3f73
commit 609123f1cc
1 changed files with 1 additions and 13 deletions

View File

@ -47,21 +47,9 @@ module Draper
options[:with] = :infer
Draper::CollectionDecorator
else
"#{association_class}Decorator".constantize
undecorated.decorator_class
end
end
def association_class
if !options[:polymorphic] && association_reflection
association_reflection.klass
else
undecorated.class
end
end
def association_reflection
@reflection ||= source.class.reflect_on_association(association) if source.class.respond_to?(:reflect_on_association)
end
end
end