mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 23:33:00 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88fce1d679 | ||
|
|
ffd8476f74 | ||
|
|
728c5ccda5 | ||
|
|
4f0c81b6f8 |
@@ -1,3 +1,6 @@
|
|||||||
|
= 1.1.7 [2009-03-26]
|
||||||
|
- Minor change to multiparameter attributes which I had not properly implemented for chaining
|
||||||
|
|
||||||
= 1.1.6 [2009-03-19]
|
= 1.1.6 [2009-03-19]
|
||||||
- Rail 2.3 support
|
- Rail 2.3 support
|
||||||
- Added :with_date and :with_time options. They allow an attribute to be combined with another attribute or value to make a datetime value for validation against the temporal restrictions
|
- Added :with_date and :with_time options. They allow an attribute to be combined with another attribute or value to make a datetime value for validation against the temporal restrictions
|
||||||
|
|||||||
2
Rakefile
2
Rakefile
@@ -5,7 +5,7 @@ require 'date'
|
|||||||
require 'spec/rake/spectask'
|
require 'spec/rake/spectask'
|
||||||
|
|
||||||
GEM = "validates_timeliness"
|
GEM = "validates_timeliness"
|
||||||
GEM_VERSION = "1.1.6"
|
GEM_VERSION = "1.1.7"
|
||||||
AUTHOR = "Adam Meehan"
|
AUTHOR = "Adam Meehan"
|
||||||
EMAIL = "adam.meehan@gmail.com"
|
EMAIL = "adam.meehan@gmail.com"
|
||||||
HOMEPAGE = "http://github.com/adzap/validates_timeliness"
|
HOMEPAGE = "http://github.com/adzap/validates_timeliness"
|
||||||
|
|||||||
@@ -16,18 +16,16 @@ module ValidatesTimeliness
|
|||||||
def execute_callstack_for_multiparameter_attributes_with_timeliness(callstack)
|
def execute_callstack_for_multiparameter_attributes_with_timeliness(callstack)
|
||||||
errors = []
|
errors = []
|
||||||
callstack.each do |name, values|
|
callstack.each do |name, values|
|
||||||
klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
|
column = column_for_attribute(name)
|
||||||
if values.empty?
|
if column && [:date, :time, :datetime].include?(column.type)
|
||||||
send(name + "=", nil)
|
|
||||||
else
|
|
||||||
column = column_for_attribute(name)
|
|
||||||
begin
|
begin
|
||||||
value = if [:date, :time, :datetime].include?(column.type)
|
callstack.delete(name)
|
||||||
time_array_to_string(values, column.type)
|
if values.empty?
|
||||||
|
send("#{name}=", nil)
|
||||||
else
|
else
|
||||||
klass.new(*values)
|
value = time_array_to_string(values, column.type)
|
||||||
|
send("#{name}=", value)
|
||||||
end
|
end
|
||||||
send(name + "=", value)
|
|
||||||
rescue => ex
|
rescue => ex
|
||||||
errors << ::ActiveRecord::AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
errors << ::ActiveRecord::AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
||||||
end
|
end
|
||||||
@@ -36,10 +34,11 @@ module ValidatesTimeliness
|
|||||||
unless errors.empty?
|
unless errors.empty?
|
||||||
raise ::ActiveRecord::MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
|
raise ::ActiveRecord::MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
|
||||||
end
|
end
|
||||||
|
execute_callstack_for_multiparameter_attributes_without_timeliness(callstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_array_to_string(values, type)
|
def time_array_to_string(values, type)
|
||||||
values = values.map(&:to_s)
|
values = values.map {|v| v.to_s }
|
||||||
|
|
||||||
case type
|
case type
|
||||||
when :date
|
when :date
|
||||||
@@ -57,7 +56,8 @@ module ValidatesTimeliness
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_time_from_multiparameter_attributes(values)
|
def extract_time_from_multiparameter_attributes(values)
|
||||||
values.last(3).map { |s| s.rjust(2, "0") }.join(":")
|
values = values.size > 3 ? values[3..5] : values
|
||||||
|
values.map { |s| s.rjust(2, "0") }.join(":")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{validates_timeliness}
|
s.name = %q{validates_timeliness}
|
||||||
s.version = "1.1.6"
|
s.version = "1.1.7"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Adam Meehan"]
|
s.authors = ["Adam Meehan"]
|
||||||
s.autorequire = %q{validates_timeliness}
|
s.autorequire = %q{validates_timeliness}
|
||||||
s.date = %q{2009-03-19}
|
s.date = %q{2009-03-26}
|
||||||
s.description = %q{Date and time validation plugin for Rails 2.x which allows custom formats}
|
s.description = %q{Date and time validation plugin for Rails 2.x which allows custom formats}
|
||||||
s.email = %q{adam.meehan@gmail.com}
|
s.email = %q{adam.meehan@gmail.com}
|
||||||
s.extra_rdoc_files = ["README.rdoc", "LICENSE", "TODO", "CHANGELOG"]
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE", "TODO", "CHANGELOG"]
|
||||||
|
|||||||
Reference in New Issue
Block a user