rails/rails — pull request #14385 by ys (2014-03-14 21:47:38+00:00)
Title: Add suffix option to store_accessor.

Adding a suffix to store accessor helps keeping the name inside the store short and clean while exposing methods that have an explicit name.

An example where this is useful is the avatars store.
Having a column that stores the different sizes of an avatar like this `{ small: 'avatar1', medium: 'avatar2' } `.
Having these methods exposed as `user.small` or `user.medium` does not make any sense.
Adding the suffix '_avatar' brings clarity. `user.small_avatar` is explicit enough.

Usage Example:

```
class User < ActiveRecord::Base
store :avatars
store_accessor :avatars, :small, :medium, :large, suffix: '_avatar'
end

u = User.new
u.small_avatar = 'Small Avatar'
u.small_avatar # => 'Small Avatar'
```