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

Lookup policies in the current namespace #152

Merged
merged 1 commit into from
May 23, 2014
Merged

Lookup policies in the current namespace #152

merged 1 commit into from
May 23, 2014

Conversation

ecbypi
Copy link
Contributor

@ecbypi ecbypi commented May 22, 2014

Addresses #12. If the policy is not defined in namespace, const_get
will search through the inheritance change of namespace to find the
policy.

Addresses #12. If the policy is not defined in `namespace`, `const_get`
will search through the inheritance change of `namespace` to find the
policy.
@adamcrown
Copy link

+1
Looks good to me and works in my namespaced app.

@ecbypi
Copy link
Contributor Author

ecbypi commented May 22, 2014

The build failed because of an issue installing rbx.

@ecbypi
Copy link
Contributor Author

ecbypi commented May 22, 2014

I submitted #153 to fix .travis.yml.

jnicklas added a commit that referenced this pull request May 23, 2014
Lookup policies in the current namespace
@jnicklas jnicklas merged commit 617b401 into varvet:master May 23, 2014
@jnicklas
Copy link
Collaborator

Very nice PR, thanks!

@ecbypi ecbypi deleted the 12-namespaced-policies branch May 23, 2014 14:58
@alec-c4
Copy link

alec-c4 commented May 29, 2014

hi,
could you please update read me with information how to use namespaces in pundit?

@alec-c4
Copy link

alec-c4 commented May 29, 2014

and if it possible - update gem :)

@thomasklemm thomasklemm mentioned this pull request Jul 13, 2014
@@ -14,7 +15,7 @@ def scope

def policy
klass = find
klass = klass.constantize if klass.is_a?(String)
klass = namespace.const_get(klass) if klass.is_a?(String)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that klass = namespace.const_get(klass) if klass.is_a?(String) will get the wrong policy if the object is namespaced which is the case for engines. Basically when klass is something like EngineName::UserPolicy and namespace EngineName::Admin const_get will not return EngineName::Admin::UserPolicy.

@llekn
Copy link

llekn commented Apr 13, 2018

Hi guys!

I saw this PR but I don't see the merged code anymore in the master branch.

I think it is a really useful feature... Why it was removed?

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.

6 participants