Skip to content

Instantly share code, notes, and snippets.

@kitop
Created November 13, 2020 15:22
Show Gist options
  • Save kitop/3f752b83b96adf99da587f8ce0b4eb02 to your computer and use it in GitHub Desktop.
Save kitop/3f752b83b96adf99da587f8ce0b4eb02 to your computer and use it in GitHub Desktop.
Mongoid public method issue
diff --git a/lib/mongoid/association/proxy.rb b/lib/mongoid/association/proxy.rb
index 6392cb799..91ecf7126 100644
--- a/lib/mongoid/association/proxy.rb
+++ b/lib/mongoid/association/proxy.rb
@@ -100,6 +100,14 @@ def substitutable
_target
end
+ def send(method, *args)
+ if respond_to?(method)
+ super
+ else
+ _target.send(method, *args)
+ end
+ end
+
protected
# Get the collection from the root of the hierarchy.
@@ -134,7 +142,7 @@ def characterize_one(document)
# @param [ Array ] args The arguments passed to the method.
#
def method_missing(name, *args, &block)
- _target.send(name, *args, &block)
+ _target.public_send(name, *args, &block)
end
# @api private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment