- Adds support for Active Record store accessors (#52)
- Adds support for Ruby 2.2.0
- Adds support for Rails 4.2.0
- [BREAKING] Removes support for Ruby 1.8.7
- [BREAKING] Removes support for Rails 3.0.x and 3.1.x
- [BREAKING] Active Record models must explicitly include ClassyEnum::ActiveRecord now
- [BREAKING] Removed use of null objects. Blank values are now returned as is from Enum.build.
- [BREAKING] Removed serialize_as_json option. #as_json should be overriden in ClassyEnum::Base subclasses instead.
- [BREAKING] Removed allow_blank option from Enum.build. This was used internally for legacy reasons and is no longer needed.
- [BREAKING] Fixes support for ActiveModel::Dirty. Now dirty attribute methods always return enum class instance (instead of string).
- [BREAKING] Removed support for Active Record queries with enum objects. Instead of
Alarm.where(priority: Priority.find(:high))
, you must convert the enum to a string so Active Record knows how to use it. Correct:Alarm.where(priority: Priority.find(:high).to_s)
. Otherwise you will get an error like "Cannot visit <Enum>". See issue #53. - Prefer 'class_name' over 'enum' as optional class name argument
- Fixes long standing issue with default values not being persisted to the database. See issue #37.
- Updates
classy_enum_attr
method to accept class_name as an argument as an alias forenum
. This is to bring the API closer to how ActiveRecord overrides class names on associations.
class Alarm < ActiveRecord::Base
classy_enum_attr :priority, enum: 'AlarmPriority'
end
is now equivalent to:
class Alarm < ActiveRecord::Base
classy_enum_attr :priority, class_name: 'AlarmPriority'
end
- Removes full Rails gem dependency in favor of ActiveRecord
- Fixes
rails destroy classy_enum MyEnum
for test unit - Fixes edge case support for Arel 4.0.1 internal change
- Fixes
rails destroy classy_enum MyEnum
so it does not remove enums directory and inadvertently remove all enum classes. - Adding license to gemspec
- Extends the existing generator to create boilerplate spec/test files. For Rspec, these files are placed in spec/enums/, for TestUnit, they are placed in test/unit/enums/
- Better support for using
default
andallow_*
options together - Fixes bug when using
default
option and explicitly setting value to nil ifallow_nil: true
option is not used. - Fixes bug when chaining
count
onto scope that uses enum object in query condition.
- Default values can now be specified within an ActiveRecord model
class Alarm < ActiveRecord::Base
classy_enum_attr :priority, :default => 'medium'
end
class Alarm < ActiveRecord::Base
classy_enum_attr :priority, :default => lambda {|enum| enum.last }
end
- Adding ClassyEnum::Base#last. It's not part of the enumerable module but it makes sense in this case.
Priority.last # => Priority::High
- Fixes saving and reloading ActiveRecord models that assign enum using class
- Allow enum property to be assigned using enum class. Previously it could only be assigned with an instance, string or symbol.
@alarm.priority = Priority::Medium
@alarm.priority.medium? # => true
- Fixes a regression with Formtastic support. ClassyEnumm::Base.build now returns a null object that decends from the base_class when the argument is blank (nil, empty string, etc). This allows the ActiveRecord model's enum attribute to respond to enum methods even if it is blank.
- ClassyEnum::Base now extends Enumerable to provide enum collection methods. All objects in the collection are instances of the enum members. .find is overridden to provide custom find functionality.
- ClassyEnum::Base.find has been reintroduced, with aliases of .detect and [].
- Introducing I18n support and providing a ClassyEnum::Base#text method that will automatically translate text values.
- Translation support was added to ClassyEnum::Base.select_options.
- Equality can now be determined using strings and symbols. The following will return true:
Priority::Low.new == :low # => true
Priority::Low.new == 'low' # => true
- Removing ClassyEnum::Base.enum_classes in favor of using enum inheritance to setup classes
- Removing ClassyEnum::Base.valid_options
- Removing ClassyEnum::Base.find
- Removing ClassyEnum::Base#name
- Removing :suffix option from classy_enum_attr
- Enforce use of namespacing for subclasses (Parent::Child < Parent)
- Use require instead of autoload
- Lots of code refactoring
- Deprecating ClassyEnum::Base#name (use to_s.titleize instead).
name
is too ambiguous and might get confused with Ruby's Class.name method. - Deprecating :suffix option from classy_enum_attr (this was a temporary hack)
- Deprecating class names like ParentChild in favor of namespaced names like Parent::Child
- Deprecating ClassyEnum::Base.enum_classes (this is no longer needed)
- Deprecating ClassyEnum::Base.valid_options (use all.join(', ') instead)
- Deprecating ClassEnum::Base.find (use build() instead)
- Fixes issue with validates_uniqueness_of when using an enum field as the scope.
- Resolving gem release conflicts, no changes
- Enum class definitions are no longer defined implicitly and must be explicitly subclassed from children of ClassyEnum::Base
- Formtastic support is not longer built-in. See https://github.com/beerlington/classy_enum/wiki/Formtastic-Support
- validates_uniqueness_of with an enum scope no longer works in Rails 3.0.x (no changes for Rails 3.1 or 3.2)
- Added support for Ruby 1.9.3
- Stop hijacking enum initialize method
- Fixed JSON recursion issue
- Added support for Rails 3.1.x
- Added support for owner enum reference
- Code refactor
- Removed support for Rails 2.x.x
- Fixed support for validates_uniqueness_of with an enum scope
- Fixed Rails dependency requirement
- Further decoupled Formtastic support
- Added
:allow_blank
option - Added blank/nil option support to Formtastic
- Fixed documentation typos
- Updated development dependencies
- Changed API for column and enum name differences
- Added Comparable support
- Fixed an issue with invalid objects set to empty string
- Added allow blank support to Formtastic
- Improved error messages
- Added "boolean" methods (i.e.
instance.enum?
) - Improved documentation
- Updated generators to make inheritance more explicit
- Removed ActiveRecord dependency
- Fixed validates_presence_of support
- Improved Formtastic support
- Changed enums to use inheritance instead of mixins
- Fixed issue with generators
- Fixed documentation typos
- Fixed documentation
- Cleaned up hacky support for Rails 3.0.x
- Fixed Formtastic load support
- Fixed validation issue in Rails 3.0.x
- Added enum generator for Rails 3.0.x
- Added support for Ruby 1.9.2
- Fixed support for apps that are not using Formtastic
- Fixed Formtastic helper support w/ Rails 3.0.x
- Added custom Formtastic input type
- Internal changes to how methods are defined
- Added enum generator for Rails 2.3.x
- Internal changes to how ActiveRecord is extended
- More test coverage
- Fixed initialized constant warning
- Initial Release