rails/rails — pull request #13433 by imanel (2013-12-21 09:36:35+00:00)
Title: Allow options for :enum and provide :nested option to create namespaced scopes and methods

This one is related to #13389 and should solve problems (1), (2) and (3) by allowing to create namespaces in such cases.

What is provided by this pull request?

```ruby
class Conversation < ActiveRecord::Base
enum :status, [ :active, :archived ], nested: true
end

Conversation.status_active

conversation.status_active!
conversation.status_active? # => true
conversation.status # => "active"
Conversation::STATUS # => { "active" => 0, "archived" => 1 }
```

Unfortunately I had to change API of enum from

```ruby
class Conversation < ActiveRecord::Base
enum status: [ :active, :archived ]
end
```

to:

```ruby
class Conversation < ActiveRecord::Base
enum :status, [ :active, :archived ]
end
```

to make sure that options are extracted. If anyone has idea how to implement it without changing API then I will be glad to modify this pull request, but we might also think about potential other options in future and try to change API now - it's up to community.