diff --git a/lib/mongoid/association/relatable.rb b/lib/mongoid/association/relatable.rb index fc485c4d94..ca201314b7 100644 --- a/lib/mongoid/association/relatable.rb +++ b/lib/mongoid/association/relatable.rb @@ -303,7 +303,7 @@ def validate? # The associations above this one in the inclusion tree. # # @return [ Array ] The associations. - attr_accessor :parent_inclusions + attr_writer :parent_inclusions # The associations above this one in the inclusion tree. # diff --git a/lib/mongoid/contextual.rb b/lib/mongoid/contextual.rb index fe0024be7e..b34aac87cd 100644 --- a/lib/mongoid/contextual.rb +++ b/lib/mongoid/contextual.rb @@ -23,7 +23,7 @@ module Contextual # The methods in the contexts themselves should all get delegated to, # including destructive, modification, and optional methods. - def_delegators :context, *(Mongo.public_instance_methods(false) - [ :skip, :limit ]) + def_delegators :context, *(Mongo.public_instance_methods(false) - [ :skip, :limit, :load_async ]) # This gets blank and empty included. def_delegators :context, *Queryable.public_instance_methods(false) diff --git a/lib/mongoid/findable.rb b/lib/mongoid/findable.rb index 93a12ce169..891c66077c 100644 --- a/lib/mongoid/findable.rb +++ b/lib/mongoid/findable.rb @@ -56,13 +56,12 @@ module Findable :take, :take!, :tally, - :text_search, :third, :third!, :third_to_last, :third_to_last!, :update, - :update_all, + :update_all # Returns a count of records in the database. # If you want to specify conditions use where. diff --git a/lib/mongoid/serializable.rb b/lib/mongoid/serializable.rb index d1c115b7ca..1f8cb81422 100644 --- a/lib/mongoid/serializable.rb +++ b/lib/mongoid/serializable.rb @@ -13,6 +13,9 @@ module Serializable included do class << self + # These methods are previously defined by ActiveModel which we override to include default behavior. + remove_method :include_root_in_json if method_defined?(:include_root_in_json) + remove_method :include_root_in_json= if method_defined?(:include_root_in_json=) def include_root_in_json @include_root_in_json.nil? ? ::Mongoid.include_root_in_json : @include_root_in_json end diff --git a/lib/mongoid/traversable.rb b/lib/mongoid/traversable.rb index 7fb26d5930..349305640e 100644 --- a/lib/mongoid/traversable.rb +++ b/lib/mongoid/traversable.rb @@ -179,8 +179,9 @@ def discriminator_value included do class_attribute :discriminator_key, instance_accessor: false - class << self + # The class attribute declaration above creates a default getter which we override with our custom method. + remove_method :discriminator_key delegate :discriminator_key, to: ::Mongoid prepend DiscriminatorAssignment include DiscriminatorRetrieval