diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2015-07-23 14:27:09 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2015-07-23 14:27:09 +0200 |
commit | ad5c1a39346d559f26c11c2399117491a3d81c0b (patch) | |
tree | 712436e163909b27b36119c0cdc5566942289674 /activerecord/lib/active_record | |
parent | 0e189cb3df7899bd99697a40b9e5f6316299ac04 (diff) | |
download | rails-ad5c1a39346d559f26c11c2399117491a3d81c0b.tar.gz rails-ad5c1a39346d559f26c11c2399117491a3d81c0b.tar.bz2 rails-ad5c1a39346d559f26c11c2399117491a3d81c0b.zip |
Rename the enum_{prefix,suffix} options to _{prefix,suffix}
This makes it more clear that they are reserved keywords and also it
seems less redundant as the line already starts with the call to the
`enum` method.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/enum.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index c0d9d9c1c8..9c9307df15 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -75,22 +75,22 @@ module ActiveRecord # # Conversation.where("status <> ?", Conversation.statuses[:archived]) # - # You can use the +:enum_prefix+ or +:enum_suffix+ options when you need - # to define multiple enums with same values. If the passed value is +true+, - # the methods are prefixed/suffixed with the name of the enum. + # You can use the +:_prefix+ or +:_suffix+ options when you need to define + # multiple enums with same values. If the passed value is +true+, the methods + # are prefixed/suffixed with the name of the enum. # # class Invoice < ActiveRecord::Base - # enum verification: [:done, :fail], enum_prefix: true + # enum verification: [:done, :fail], _prefix: true # end # - # It is also possible to supply a custom prefix. + # It is also possible to supply a custom value: # # class Invoice < ActiveRecord::Base - # enum verification: [:done, :fail], enum_prefix: :verification_status + # enum verification: [:done, :fail], _prefix: :verification_status # end # - # Note that <tt>:enum_prefix</tt>/<tt>:enum_suffix</tt> are reserved keywords - # and can not be used as an enum name. + # Note that <tt>:_prefix</tt>/<tt>:_suffix</tt> are reserved keywords and can + # not be used as enum names. module Enum def self.extended(base) # :nodoc: @@ -137,8 +137,8 @@ module ActiveRecord def enum(definitions) klass = self - enum_prefix = definitions.delete(:enum_prefix) - enum_suffix = definitions.delete(:enum_suffix) + enum_prefix = definitions.delete(:_prefix) + enum_suffix = definitions.delete(:_suffix) definitions.each do |name, values| # statuses = { } enum_values = ActiveSupport::HashWithIndifferentAccess.new |