validates_timeliness 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/TODO +4 -0
- data/lib/validates_timeliness/active_record/multiparameter_attributes.rb +11 -11
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
= 1.1.7 [2009-03-26]
|
2
|
+
- Minor change to multiparameter attributes which I had not properly implemented for chaining
|
3
|
+
|
1
4
|
= 1.1.6 [2009-03-19]
|
2
5
|
- Rail 2.3 support
|
3
6
|
- 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
|
data/Rakefile
CHANGED
data/TODO
CHANGED
@@ -16,18 +16,16 @@ module ValidatesTimeliness
|
|
16
16
|
def execute_callstack_for_multiparameter_attributes_with_timeliness(callstack)
|
17
17
|
errors = []
|
18
18
|
callstack.each do |name, values|
|
19
|
-
|
20
|
-
if
|
21
|
-
send(name + "=", nil)
|
22
|
-
else
|
23
|
-
column = column_for_attribute(name)
|
19
|
+
column = column_for_attribute(name)
|
20
|
+
if column && [:date, :time, :datetime].include?(column.type)
|
24
21
|
begin
|
25
|
-
|
26
|
-
|
22
|
+
callstack.delete(name)
|
23
|
+
if values.empty?
|
24
|
+
send("#{name}=", nil)
|
27
25
|
else
|
28
|
-
|
26
|
+
value = time_array_to_string(values, column.type)
|
27
|
+
send("#{name}=", value)
|
29
28
|
end
|
30
|
-
send(name + "=", value)
|
31
29
|
rescue => ex
|
32
30
|
errors << ::ActiveRecord::AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
33
31
|
end
|
@@ -36,10 +34,11 @@ module ValidatesTimeliness
|
|
36
34
|
unless errors.empty?
|
37
35
|
raise ::ActiveRecord::MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
|
38
36
|
end
|
37
|
+
execute_callstack_for_multiparameter_attributes_without_timeliness(callstack)
|
39
38
|
end
|
40
39
|
|
41
40
|
def time_array_to_string(values, type)
|
42
|
-
values = values.map
|
41
|
+
values = values.map {|v| v.to_s }
|
43
42
|
|
44
43
|
case type
|
45
44
|
when :date
|
@@ -57,7 +56,8 @@ module ValidatesTimeliness
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def extract_time_from_multiparameter_attributes(values)
|
60
|
-
values.
|
59
|
+
values = values.size > 3 ? values[3..5] : values
|
60
|
+
values.map { |s| s.rjust(2, "0") }.join(":")
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Meehan
|
@@ -9,7 +9,7 @@ autorequire: validates_timeliness
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-26 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|