README.rdoc in enumerate_it-0.7.8 vs README.rdoc in enumerate_it-0.7.9
- old
+ new
@@ -72,10 +72,27 @@
* You can manipulate the hash used to create the enumeration:
RelationshipStatus.enumeration # returns the exact hash used to define the enumeration
+You can also create enumerations in the following ways:
+
+* Passing an array of symbols, so that the respective value for each symbol will be the stringified version of the symbol itself:
+
+ class RelationshipStatus < EnumerateIt::Base
+ associate_values :married, :single
+ end
+
+ RelationshipStatus::MARRIED # returns "married" and so on
+
+* Passing hashes where the value for each key/pair does not include a translation. In this case, the I18n feature will be used (more on this below):
+
+ class RelationshipStatus < EnumerateIt::Base
+ associate_values :married => 1, :single => 2
+ end
+
+
== Using enumerations
The cool part is that you can use these enumerations with any class, be it an ActiveRecord instance
or not.
@@ -109,10 +126,10 @@
p.relationship_status = RelationshipStatus::MARRIED
p.relationship_status_humanize # => 'Married'
* The associated enumerations can be retrieved with the 'enumerations' class method.
- Person.enumerations[:relationship_status] # => RelationshipStatus
+ Person.enumerations[:relationship_status] # => RelationshipStatus
* If you pass the :create_helpers option as 'true', it will create a helper method for each enumeration option (this option defaults to false):
class Person < ActiveRecord::Base
has_enumeration_for :relationship_status, :with => RelationshipStatus, :create_helpers => true