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

New methods to retrieve 1 or more guards from the list of running guards #121

Closed
rymai opened this issue Aug 14, 2011 · 7 comments
Closed
Assignees
Milestone

Comments

@rymai
Copy link
Member

rymai commented Aug 14, 2011

As discussed in #118, we could "add a little helper method to Guard that allows you to get a guard like Guard.get_guard(:less)" (@netzpirat).

I agree with @ches on "using a hash instead of keyword arguments", as it seems to be the best choice. We could even have 2 methods:

Guard.get_guards(filters={}) (return an array of guards)

and

Guard.get_guard(filters={}) (return the first guard that matches).

with filters a hash like this: { :name => :less, :group => :foobar } (this would return only the guard-less that is present in the "foobar" group).

Thoughts welcome!

@ches
Copy link
Contributor

ches commented Aug 14, 2011

Another idea comes to mind: don't even use a separately named helper, just implement Guard.guards as a richer reader method instead of using attr_accessor for it. This can still return an array as it does in the established API, but accept the filter hash as a parameter.

@rymai
Copy link
Member Author

rymai commented Aug 14, 2011

Very smart indeed! :)

Sent from my iPhone

On 14 août 2011, at 23:36, ches reply@reply.github.com wrote:

Another idea comes to mind: don't even use a separately named helper, just implement Guard.guards as a richer reader method instead of using attr_accessor for it. This can still return an array as it does in the established API, but accept the filter hash as a parameter.

Reply to this email directly or view it on GitHub:
#121 (comment)

@ghost ghost assigned rymai Sep 22, 2011
@rymai
Copy link
Member Author

rymai commented Sep 22, 2011

Ok, I've now implemented a first version of your suggestion.

Guard.guards('less') will find the first Guard::Less instance, Guard.guards(:group => 'frontend') will return all Guards in the 'frontend' group, Guard.guards(:group => 'frontend', :name => 'less') will return all Guard::Less instances in the 'frontend' group.

Thanks again @ches!

@rymai rymai closed this as completed Sep 22, 2011
@ches
Copy link
Contributor

ches commented Sep 23, 2011

Awesome! Hope I can find a chance to play with it soon. Thanks for hearing suggestions and implementing them :-)

@rymai
Copy link
Member Author

rymai commented Sep 23, 2011

No problem, it's always a pleasure. And you're acknowledged in the CHANGELOG! ;)

@ches
Copy link
Contributor

ches commented Sep 23, 2011

An awfully generous credit, thanks :-)

@rymai
Copy link
Member Author

rymai commented Sep 23, 2011

Aha, everyone should be thanked, regardless of the contribution's impact (and it's free so... :D)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants