diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-08-12 19:57:12 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-07 08:10:02 +0900 |
commit | 89dc8e1ff87d86c4253fa6dcd0002eb64fa4e922 (patch) | |
tree | 277d2786a4f0e7468c1fd34bf543da9949de2ec1 | |
parent | 3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75 (diff) | |
download | rails-89dc8e1ff87d86c4253fa6dcd0002eb64fa4e922.tar.gz rails-89dc8e1ff87d86c4253fa6dcd0002eb64fa4e922.tar.bz2 rails-89dc8e1ff87d86c4253fa6dcd0002eb64fa4e922.zip |
`RuntimeReflection` is not a subclass of `PolymorphicReflection`
`PolymorphicReflection` is an internal class that is used in
`ThroughReflection`. But `RuntimeReflection` is used for the head of
chain in `AssociationScope`. These are totally different things.
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index a01eb7b242..7b3bcc33bf 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -138,7 +138,7 @@ module ActiveRecord # HasAndBelongsToManyReflection # ThroughReflection # PolymorphicReflection - # RuntimeReflection + # RuntimeReflection class AbstractReflection # :nodoc: def through_reflection? false @@ -1029,6 +1029,8 @@ module ActiveRecord end class PolymorphicReflection < AbstractReflection # :nodoc: + delegate :klass, :scope, :plural_name, :type, :get_join_keys, to: :@reflection + def initialize(reflection, previous_reflection) @reflection = reflection @previous_reflection = previous_reflection @@ -1044,30 +1046,10 @@ module ActiveRecord scopes << @previous_reflection.source_type_scope end - def klass - @reflection.klass - end - - def scope - @reflection.scope - end - - def plural_name - @reflection.plural_name - end - - def type - @reflection.type - end - def constraints @reflection.constraints + [source_type_info] end - def get_join_keys(association_klass) - @reflection.get_join_keys(association_klass) - end - private def source_type_info type = @previous_reflection.foreign_type @@ -1076,7 +1058,9 @@ module ActiveRecord end end - class RuntimeReflection < PolymorphicReflection # :nodoc: + class RuntimeReflection < AbstractReflection # :nodoc: + delegate :scope, :type, :constraints, :get_join_keys, to: :@reflection + def initialize(reflection, association) @reflection = reflection @association = association @@ -1086,10 +1070,6 @@ module ActiveRecord @association.klass end - def constraints - @reflection.constraints - end - def alias_name Arel::Table.new(table_name, type_caster: klass.type_caster) end |