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

Add filename lineno to class_eval and module_eval calls #4368

Merged

Conversation

ivanovaleksey
Copy link
Contributor

No description provided.

def #{name}(*args, &block)
#{receiver}.__send__(:#{name}, *args, &block)
end
SEL
else
(class << self; self; end).class_eval <<-SEL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(class << self; self; end) does return singleton class of self, doesn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

@estolfo
Copy link
Contributor

estolfo commented Dec 22, 2016

Hi @ivanovaleksey

Can you tell me what problem you are solving with this PR? Thanks

@ivanovaleksey
Copy link
Contributor Author

ivanovaleksey commented Dec 22, 2016

Hi @estolfo

Initially I was looking for where is or method defined.
So I tried

or_method = User.method(:or)
or_method.source_location
# => ["(eval)", 1]

With this PR it would be

or_method.source_location
# ["/Users/aleksey/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/origin-2.3.0/lib/origin/forwardable.rb", 48]

Of course now I know where all these methods are defined but I thought it could be useful for others.

As you know in case of an error __FILE__ and __LINE__ in module_eval also show where really an error happened. I am not sure there could be much errors since these methods are not complicated but I thought it would not be superfluous.

@ivanovaleksey
Copy link
Contributor Author

By the way there is issue for origin gem with the same suggestion.

@estolfo
Copy link
Contributor

estolfo commented Jan 17, 2017

Thanks!

@estolfo estolfo merged commit 67f0b97 into mongodb:master Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants