The ActiveModel type system with extensions in ActiveRecord provide
us a lot of convenience. Some general attribute code is now moved to
ActiveModel only as the AR types provide raw value capturing
(before_type_cast) and type classes to handle type specific string
value parsing if enabled.
In my view, we need to go futher and strip out more from ActiveModel
extension but at least we should have compatibility at the moment.
Multiparamter extension used to do a lot of crappy work to ensure that
the invalid Date dates were not accepted, but also to store a
before_type_cast value in cases when it was invalid. We no longer need
to handle the before_type_cast value as ActiveRecord does that nicely.
Now we just ensure values to cast with a invalid date parts is not
accepted.
This would eliminate the need to keeping multiple copies for the default keys set defined by gem.
The following seems more apt than the later one:
```
validates_date :start_at, on_or_after: :today, message: 'should not be in past'
```
```
validates_date :start_at, on_or_after: :today, on_or_after_message: 'should not be in past'
```
This is a memory and performance improvement change.
The attribute methods for timeliness are generated at each object creation instead of once, at first creation like AR attribute methods. Since creating those methods uses `module_eval` it's quite slow when it's done each `Model.new`.
For more details on the performance improvement, see the same change on John Carney's fork: https://github.com/johncarney/validates_timeliness/pull/6
- Now requires Mongoid 3.0 as minimum version (this is the only version to support Rails 3.2)
- Upgrade specs/helpers for Mongoid 3
- Support Mongoid aliased field names (e.g. field :foo, as: bar, type: String). Includes spec
- Support before_type_cast on Mongoid. No code change was required for this, only a spec change.
- There was one mongoid spec that was previously marked pending. I've found that it now works on Mongoid 3.
- Removed some Mongoid 2.3 and earlier hacks, which simplifies the Mongoid ORM code.