add validator type accessor

This commit is contained in:
Adam Meehan 2010-08-03 15:07:23 +10:00
parent 7117a5ef22
commit b22a7c41b8
2 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,8 @@ module ValidatesTimeliness
class Validator < ActiveModel::EachValidator
include Conversion
attr_reader :type
RESTRICTIONS = {
:is_at => :==,
:before => :<,

View File

@ -22,7 +22,7 @@ describe ValidatesTimeliness::Validator do
it 'should use default to :datetime type' do
Person.validates :birth_datetime, :timeliness => {:is_at => Time.mktime(2010,1,1)}
Person.validators.first.instance_variable_get(:@type).should == :datetime
Person.validators.first.type.should == :datetime
end
end