Module: PolyBelongsTo::SortedReflectionDecorator

Defined in:
lib/poly_belongs_to/sorted_reflection_decorator.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/poly_belongs_to/sorted_reflection_decorator.rb', line 3

def self.included(base)
  base.module_exec do
    original_method = instance_method(:reflect_on_all_associations)
    define_method(:reflect_on_all_associations) do |*args, &block|
      original_method.bind(self).call(*args, &block).sort_by {|a| a.polymorphic? ? 0 : 1 }
    end
  end
end