Skip to content

Commit

Permalink
add comments to explain remove_method
Browse files Browse the repository at this point in the history
  • Loading branch information
DarshanaVenkatesh committed Dec 16, 2024
1 parent 1696b1d commit b4b3dde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/mongoid/serializable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ module Serializable
included do

class << self
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=)
# 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
Expand Down
3 changes: 2 additions & 1 deletion lib/mongoid/traversable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def discriminator_value
included do
class_attribute :discriminator_key, instance_accessor: false
class << self
remove_method :discriminator_key if method_defined?(:discriminator_key)
# 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
Expand Down

0 comments on commit b4b3dde

Please sign in to comment.