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

Keyword arguments support? #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chastell
Copy link
Contributor

@chastell chastell commented Jan 3, 2015

Is there a chance for after_do to have keyword arguments support?

I was hoping for something like

@dummy_class.send callback_adder, :kwargs do |defd:, reqd:|
  mockie.call_method defd: defd, reqd: reqd
end

but I think the invisible object argument at the end makes it blow up (you can’t have non-kwargs after kwargs).

The best I could do is to fake them via a Hash access (as in this PR), which might be the best that can be done while preserving the optional object.

Note that this PR probably won’t even build outside of MRI 2.1 and 2.2 – once the decision whether/how to support kwargs is made I can try wiring the specs so that kwarg-related ones are only ran on kwarg-capable Rubies.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 0cb1106 on chastell:kwarg_support into 6d1bce2 on PragTob:master.

@PragTob
Copy link
Owner

PragTob commented Jan 5, 2015

Helllooooo! :)

So thanks for this, frankly I never thought about kwargs as I have yet to use them :) The way you did it is the only way I can imagine doing it right now.

About the optional object, that's pretty important so it has to stay. If the problem is that the object is last we could experiment with reversing the order. Of course that would be breaking, but hey it's 0.x - maybe it is worth it.

Thanks Piotr! :)

@PragTob
Copy link
Owner

PragTob commented Jan 14, 2017

Hello my dear @chastell !

In the last versions the data AfterDo has access to has grown extensively.

After I cut out 0.5.0 I'd be ready to investigate an overhaul of the API where one just picks and matches with keyword arguments which values you want to get. I'm also completely ok with dropping support for 1.9 or even early 2.x versions. AfterDo has been rather stable and who doesn't have these versions can stay and stick to versions 0.5 and below (most still depend on 0.3 it seems).

If you wanna pitch in there, I'd be happy too - or maybe I get another reason to visit you and we pair on the new versions?

Anyhow, hugs!

@PragTob PragTob changed the base branch from master to main July 5, 2020 09:27
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