Class: ActiveRecord::Reflection::PolymorphicReflection
- Inherits:
-
Object
- Object
- ActiveRecord::Reflection::PolymorphicReflection
- Defined in:
- lib/store_base_sti_class_for_5_0.rb,
lib/store_base_sti_class_for_5_1.rb,
lib/store_base_sti_class_for_5_2.rb,
lib/store_base_sti_class_for_6_0.rb,
lib/store_base_sti_class_for_6_1.rb
Instance Method Summary collapse
Instance Method Details
#source_type_info ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/store_base_sti_class_for_5_0.rb', line 369 def source_type_info type = @previous_reflection.foreign_type source_type = @previous_reflection.[:source_type] # START PATCH adjusted_source_type = if ActiveRecord::Base.store_base_sti_class source_type else ([source_type.constantize] + source_type.constantize.descendants).map(&:to_s) end # END PATCH lambda { |object| where(type => adjusted_source_type) } end |
#source_type_scope ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/store_base_sti_class_for_5_2.rb', line 157 def source_type_scope type = @previous_reflection.foreign_type source_type = @previous_reflection.[:source_type] # START PATCH adjusted_source_type = if ActiveRecord::Base.store_base_sti_class source_type else ([source_type.constantize] + source_type.constantize.descendants).map(&:to_s) end # END PATCH lambda { |object| where(type => adjusted_source_type) } end |