rails/rails — pull request #14827 by edelpero (2014-04-20 21:23:46+00:00)
Title: Adds the ability to pass options to enum

I love Rails flexibility and I thought it would be nice if you could pass some options to enum. You can pass options to enum as a block:

```ruby
class Conversation < ActiveRecord::Base
enum status: { active: 0, archived: 1 } do |config|
config.skip = :writer, :reader, :accessor, :question_marks, :updates, :scopes
config.prefix = true
end
end
```

**skip** will avoid creating methods you don't want, you don't need or want to avoid some collision. If you pass:

- ***:writer***, this will avoid overriding `conversation.status=`
- ***:reader***, this will avoid overriding `conversation.status`
- ***:accessor***, this will avoid overriding `conversation.status=` and `conversation.status`
- ***:question_marks***, this will avoid defining `conversation.active?` and `conversation.archived?`
- ***:updates***, this will avoid defining `conversation.active!` and `conversation.archived!`
- ***:scopes***, this will avoid defining `Conversation.active` and `Conversation.archived`

**prefix** will add the name of the field as a prefix to the new defined methods:

```ruby
conversation.status_active! # update method
conversation.status_active? # question_mark method
Conversation.status_active # scope method
```