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

Aquarium::Finders::TypeFinder#empty #37

Open
paulwalker opened this issue Dec 31, 2012 · 3 comments
Open

Aquarium::Finders::TypeFinder#empty #37

paulwalker opened this issue Dec 31, 2012 · 3 comments

Comments

@paulwalker
Copy link

I am not sure what the purpose of the empty? part of this empty method is, but it may cause an issue when creating aspects on types that use that method for other purposes than what I believe is what is intended here. For example. MongoMapper document types use it to query the document collection, which actually raises a NameError when the connection has not been set yet (which is likely when aspect code interpreted). Consider removal of the empty? half of this condition?

@deanwampler
Copy link
Contributor

It's only used within TypeFinder at two point to weed out empty strings and regular expressions. It should never be called on other types or objects that you might be advising. It, and most of the other helper methods, should be protected, though.

@paulwalker
Copy link
Author

Hmm...I don't see any type checking in the condition and #empty? is actually happening on the class I defined in the Aspect. Could it be because I am not using an array on on_types?

opts = { :calls_to => [method_name], :on_types => self }
Aquarium::Aspects::Aspect.new(:around, opts) do |jp, object, *args|

@deanwampler
Copy link
Contributor

It's true that no type checking is done.

With ":on_types => self", are you trying to match all instances of the enclosing type or just the current instance? If the former, try changing "self" to the class name (even if you don't want to hard code this, it would be interesting to see if it avoids the issue).

If the latter, what happens if you change :on_types => self to :on_objects => self?

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

No branches or pull requests

2 participants