While working with the Ruby gem Pundit, I realized I was unsure of the way some namespacing works within Ruby and I do not like mysteries/uncertainties in my mind.
Pundit suggests you set up an application_policy.rb
as so:
class ApplicationPolicy
class Scope
.
.
.
end
end
What actually is happening inside of the class doesn't matter, just the structure of the classes do.
Then you specify a policy for a particular resource that inherits from ApplicationPolicy
, say post_policy.rb
as so:
class PostPolicy < ApplicationPolicy
class Scope < Scope
end
end
My general question is, inside my PostPolicy
, when I declare that Scope < Scope
, what does the parent Scope
refer to? Does it automatically get namespaced within the parent of the outer class? So is it essentially the same as inheriting from ApplicationPolicy::Scope
? I am having trouble finding a way to answer this on my own, thanks!