Skip to content

Commit

Permalink
Move documentation around a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Nov 3, 2013
1 parent 0342335 commit fe97734
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions activerecord/lib/active_record/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module ActiveRecord
# Declare an enum attribute where the values map to integers in the database, but can be queried by name. Example:
#
# class Conversation < ActiveRecord::Base
# enum status: [:active, :archived]
#
# # same but with explicit mapping
# enum status: {active: 0, archived: 1}
# enum status: [ :active, :archived ]
# end
#
# Conversation::STATUS # => { active: 0, archived: 1 }
Expand All @@ -30,6 +27,12 @@ module ActiveRecord
# end
#
# Good practice is to let the first declared status be the default.
#
# Finally, it's also possible to explicitly map the relation between attribute and database integer:
#
# class Conversation < ActiveRecord::Base
# enum status: { active: 0, archived: 1 }
# end
module Enum
def enum(definitions)
definitions.each do |name, values|
Expand Down

0 comments on commit fe97734

Please sign in to comment.