Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONGOID-5809: remove ruby -w warnings #5921

Merged
2 changes: 1 addition & 1 deletion lib/mongoid/association/relatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def validate?
# The associations above this one in the inclusion tree.
#
# @return [ Array<String> ] The associations.
attr_accessor :parent_inclusions
attr_writer :parent_inclusions

# The associations above this one in the inclusion tree.
#
Expand Down
8 changes: 6 additions & 2 deletions lib/mongoid/contextual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -47,7 +47,11 @@ def context
#
# @return [ Criteria ] Returns self.
def load_async
context.load_async if context.respond_to?(:load_async)
if context.respond_to?(:load_async)
context.load_async
else
Mongo.instance_method(:load_async).bind(context).call
end
self
end

Expand Down
3 changes: 1 addition & 2 deletions lib/mongoid/findable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lib/mongoid/serializable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ 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=)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I had to dig a bit to understand that these methods are defined in ActiveModel, and we're just re-defining them here to account for our default value Mongoid.include_root_in_json. Maybe add a comment to that effect?

Also, there's an extra space before these lines -- we've standardized on indentations in 2-space increments.

def include_root_in_json
@include_root_in_json.nil? ? ::Mongoid.include_root_in_json : @include_root_in_json
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid/traversable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def discriminator_value

included do
class_attribute :discriminator_key, instance_accessor: false

class << self
remove_method :discriminator_key if method_defined?(:discriminator_key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here -- please add a comment explaining that the preceding class_attribute creates both a getter and a setter, but we need to reimplement the getter (by delegating).

Also, the if method_defined?(...) is unnecessary here, since we know that the preceding class_attribute ensures the method is defined. 👍

delegate :discriminator_key, to: ::Mongoid
prepend DiscriminatorAssignment
include DiscriminatorRetrieval
Expand Down
Loading