lwe/simple_enum — pull request #90 by bbtfr (2014-10-29 03:09:48+00:00)
Title: add multi-select support

I saw @sibevin 's PR, and I think it's a great work.
Here is my implement of multi-enums with additional accessors.

To make the accessor more powerful, there are 2 new methods added to `SimpleEnum::Accessors::Accessor` base class: `init` and `scope`.
With `init` method, we are able to change the model class, eg: add some new methods, and with `scope` method, we can handle enum scope method, cause the scope method for multi-enums is always much more complex than a where clause.

By default, `_cds` suffix is used to store enum array, eg: `favorite_cds` for `favorites` enum. we can change it by changing `SimpleEnum.multi_suffix`.

And then, there are 3 new accessors: `MultipleAccessor`, `JoinTableAccessor` and `BitwiseAccessor`:

`MultipleAccessor` is the base accessor for all the other multi-accessors, it defines how to serialize the enums to values, and this accessor will __not__ handle how the data saved in the database. So, we have to use it in this way:
```
serialize :favorite_cds
as_enum :favorites, { ipad: 0, iphone: 1, macbook: 2 }, accessor: :multiple
```

`JoinTableAccessor` will store multi-enums data in a join table, we can use it in this way:
```
# Migration
create_join_table :users, :tags

# Model
as_enum :tags, [:iphone, :ipad, :macbook], accessor: :join_table
```

`BitwiseAccessor` will store multi-enums data in a integer column:
```
# Migration
add_column :posts, :tag_cds, :integer

# Model
as_enum :tags, [:iphone, :ipad, :macbook], accessor: :bitwise
```

I think it's a big change to SimpleEnum, so maybe we can keep it in a new gem, as a plugin of SimpleEnum,
but I think it would be great if `init` and `scope` can be added into `SimpleEnum::Accessors::Accessor`, to make it more flexible.