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:
parent
f0a1be3f73
commit
609123f1cc
1 changed files with 1 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue