elabs/pundit — pull request #159 by americodls (2014-06-08 03:43:28+00:00)
Title: Using Struct properly

This proposal is based in this doc: http://www.ruby-doc.org/core-2.1.2/Struct.html

> This is the recommended way to customize a struct. Subclassing an anonymous struct creates an extra anonymous class that will never be used.

The difference can be observed below (notice the extra anonymous class in the ancestors chain):

```ruby
class PostPolicy < Struct.new(:user, :post); end
PostPolicy.ancestors
#=> [PostPolicy, #, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject]
```

```ruby
PostPolicy = Struct.new(:user, :post)
PostPolicy.ancestors
#=> [PostPolicy, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject]
```