1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00
activerecord-hackery--ransack/lib/polyamorous/swapping_reflection_class.rb
2020-04-02 20:13:33 -04:00

11 lines
379 B
Ruby

module Polyamorous
module SwappingReflectionClass
def swapping_reflection_klass(reflection, klass)
new_reflection = reflection.clone
new_reflection.instance_variable_set(:@options, reflection.options.clone)
new_reflection.options.delete(:polymorphic)
new_reflection.instance_variable_set(:@klass, klass)
yield new_reflection
end
end
end