diff options
author | Arthur Nogueira Neves <github@arthurnn.com> | 2016-01-31 18:32:14 -0500 |
---|---|---|
committer | Arthur Nogueira Neves <github@arthurnn.com> | 2016-01-31 18:32:14 -0500 |
commit | b98ca654b87de58a8c83184306a40a85884b1132 (patch) | |
tree | d9f9c01a9b81191563845541d8c870399ef23bd6 /activerecord | |
parent | 5c9cccaf25888836aacbca24dbbe8e94d0d61eac (diff) | |
parent | 615dcadba0c18e332a497c515b66215c446dfe1d (diff) | |
download | rails-b98ca654b87de58a8c83184306a40a85884b1132.tar.gz rails-b98ca654b87de58a8c83184306a40a85884b1132.tar.bz2 rails-b98ca654b87de58a8c83184306a40a85884b1132.zip |
Merge pull request #23380 from yui-knk/override_calculate_constructables_at_each_concrete_class
Remove `case macro` from `calculate_constructable`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index cbb5b99a05..823ca1f54f 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -501,14 +501,7 @@ module ActiveRecord private def calculate_constructable(macro, options) - case macro - when :belongs_to - !polymorphic? - when :has_one - !options[:through] - else - true - end + true end # Attempts to find the inverse association name automatically. @@ -634,6 +627,12 @@ module ActiveRecord Associations::HasOneAssociation end end + + private + + def calculate_constructable(macro, options) + !options[:through] + end end class BelongsToReflection < AssociationReflection # :nodoc: @@ -661,6 +660,12 @@ module ActiveRecord def join_id_for(owner) # :nodoc: owner[foreign_key] end + + private + + def calculate_constructable(macro, options) + !polymorphic? + end end class HasAndBelongsToManyReflection < AssociationReflection # :nodoc: |