-
Notifications
You must be signed in to change notification settings - Fork 323
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
use_api accepts Procs #166
Conversation
Added patch -procs to version number
This looks good. Could you remove the changed lines in |
Added patch -procs to version number
Done. Sorry about that. |
It’s failing on ruby 1.8.7, we’ll have to use |
Changed that. |
@@ -39,9 +39,13 @@ def use_api(value = nil) | |||
superclass.use_api if superclass.respond_to?(:use_api) | |||
end | |||
|
|||
return @_her_use_api unless value | |||
unless value | |||
return (@_her_use_api.class == Proc) ? @_her_use_api.call : @_her_use_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing, instead of testing the class, I’d test if @_her_use_api
responds to #call
.
That’s it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea :)
Still failing on 1.8.7 because of the new hash syntax. |
Sorry. I missed that bit. |
Thanks for your help! |
What is the eta on get this released to rubygems? |
/cc @remiprev |
We had a use case where we needed to use procs to dynamically set the api for uses_api based on model extensions. We added the code and test to do that. If you have a better idea we are completely open to suggestions.