Module: Polyamorous::SwappingReflectionClass

Included in:
JoinAssociationExtensions
Defined in:
lib/polyamorous/swapping_reflection_class.rb

Instance Method Summary collapse

Instance Method Details

#swapping_reflection_klass(reflection, klass) {|new_reflection| ... } ⇒ Object

Yields:

  • (new_reflection)


3
4
5
6
7
8
9
# File 'lib/polyamorous/swapping_reflection_class.rb', line 3

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