README.rdoc in enumerate_it-1.0.3 vs README.rdoc in enumerate_it-1.1.0

- old
+ new

@@ -115,11 +115,27 @@ class RelationshipStatus < EnumerateIt::Base associate_values :married => 1, :single => 2 end +=== Defining a default sort mode +When calling methods like `to_a` and `to_json`, the returned values will be sorted using the translation for each one of the enumeration values. If you want +to overwrite the default sort mode, you can use the `sort_mode` class method. + + class RelationshipStatus < EnumerateIt::Base + associate_values :married => 1, :single => 2 + + sort_by :value + end + +The `sort_by` methods accept one of the following values: + +* `:translation`: The default behavior, will sort the returned values based on translations. +* `:value`: Will sort the returned values based on values. +* `:name`: Will sort the returned values based on the name of each enumeration option. + == Using enumerations The cool part is that you can use these enumerations with any class, be it an ActiveRecord instance or not. @@ -280,10 +296,10 @@ end end There is also a Rails Generator that you can use to generate enumerations and their locale files. Take a look at how to use it running - rails generate enumerate_it --help + rails generate enumerate_it:enum --help == Why did you reinvent the wheel? There are other similar solutions to the problem out there, but I could not find one that worked both with strings and integers as the enumerations' codes. I had both situations in