1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

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

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