Browse files

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.
  • Loading branch information...
1 parent f0a1be3 commit 609123f1cc3f6518c93fb18f3d62572ea0bec360 @haines haines committed Nov 8, 2012
Showing with 1 addition and 13 deletions.
  1. +1 −13 lib/draper/decorated_association.rb
View
14 lib/draper/decorated_association.rb
@@ -47,21 +47,9 @@ def decorator_class
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

0 comments on commit 609123f

Please sign in to comment.