From 631347b78be3cb5cf3d93da3b65bfe76e379496e Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Mon, 17 Mar 2014 22:45:16 +0100 Subject: [PATCH] Change back to inheriting from Struct Inheriting from Struct actually has no real downsides, and the alternative makes my eyes bleed. An additional anonymous class? Who cares. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f954e39..dee8375 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ As you can see, this is just a plain Ruby class. As a convenience, we can inheri from Struct or use Struct.new to define the policy class: ``` ruby -PostPolicy = Struct.new(:user, :post) do +class PostPolicy < Struct.new(:user, :post) def update? user.admin? or not post.published? end @@ -162,8 +162,8 @@ particular user has access to. When using Pundit, you are expected to define a class called a policy scope. It can look something like this: ``` ruby -PostPolicy = Struct.new(:user, :post) do - self::Scope = Struct.new(:user, :scope) do +class PostPolicy < Struct.new(:user, :post) + class Scope < Struct.new(:user, :scope) def resolve if user.admin? scope.all