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

use_api accepts Procs #166

Merged
merged 7 commits into from
Aug 6, 2013
Merged

use_api accepts Procs #166

merged 7 commits into from
Aug 6, 2013

Conversation

m3talsmith
Copy link
Contributor

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.

Added patch -procs to version number
@remi
Copy link
Owner

remi commented Aug 6, 2013

This looks good. Could you remove the changed lines in .gitignore and version.rb so I can merge it? Thank you!

@m3talsmith
Copy link
Contributor Author

Done. Sorry about that.

@remi
Copy link
Owner

remi commented Aug 6, 2013

It’s failing on ruby 1.8.7, we’ll have to use lambda instead of ->.

@m3talsmith
Copy link
Contributor Author

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
Copy link
Owner

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 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea :)

@remi
Copy link
Owner

remi commented Aug 6, 2013

Still failing on 1.8.7 because of the new hash syntax.

@m3talsmith
Copy link
Contributor Author

Sorry. I missed that bit.

remi added a commit that referenced this pull request Aug 6, 2013
@remi remi merged commit e8d5d31 into remi:master Aug 6, 2013
@remi
Copy link
Owner

remi commented Aug 6, 2013

Thanks for your help!

@trobrock
Copy link

What is the eta on get this released to rubygems?

@trobrock
Copy link

trobrock commented Sep 6, 2013

/cc @remiprev

@pencil pencil mentioned this pull request Oct 15, 2013
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.

3 participants