mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
![]() The `BlogPolicy -> "BlogPolicy" -> "Blog" -> "BlogPolicy" -> BlogPolicy` issue @jnicklas pointed out has been resolved. For example, given ```ruby class BlogPolicy < Struct.new(:user, :blog); end class Blog; end class ArtificialBlog < Blog def self.policy_class BlogPolicy end end ``` The above string manipulation/casting is prevented; the `BlogPolicy` class will be immediately returned to `policy` and on to be evaluated. Anonymous classes are now supported too. For example, given ```ruby class BlogPolicy < Struct.new(:user, :blog); end class Blog; end class ArtificialBlog < Blog def self.policy_class Struct.new(:user, :blog) do def create? true end end end end ``` The `Struct` will be returned and evaluated as any other policy. |
||
---|---|---|
.. | ||
pundit_spec.rb |