Skip to content

Commit 5164d5b

Browse files
committed
Refactor Lock mixin to an abstract FixedValue superclass
To avoid confusing rule validation mixins with the special "Lock" mixin that was used in the internal `*::Validation` classes, this is now a superclass. Also renamed to `FixedValue` to avoid confusion with `ScheduleLock`.
1 parent 26b129b commit 5164d5b

File tree

9 files changed

+15
-30
lines changed

9 files changed

+15
-30
lines changed

lib/ice_cube.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ module IceCube
3434
autoload :YearlyRule, 'ice_cube/rules/yearly_rule'
3535

3636
module Validations
37-
38-
autoload :Lock, 'ice_cube/validations/lock'
37+
autoload :FixedValue, 'ice_cube/validations/fixed_value'
3938
autoload :ScheduleLock, 'ice_cube/validations/schedule_lock'
4039

4140
autoload :Count, 'ice_cube/validations/count'

lib/ice_cube/validations/day.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def day(*days)
1616
self
1717
end
1818

19-
class Validation
20-
21-
include Validations::Lock
19+
class Validation < Validations::FixedValue
2220

2321
attr_reader :day
2422
alias :value :day

lib/ice_cube/validations/day_of_month.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ def day_of_month(*days)
1313
self
1414
end
1515

16-
class Validation
17-
18-
include Validations::Lock
16+
class Validation < Validations::FixedValue
1917

2018
attr_reader :day
2119
alias :value :day

lib/ice_cube/validations/lock.rb renamed to lib/ice_cube/validations/fixed_value.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module IceCube
22

3-
# This validation mixin is used by the various "fixed-time" (e.g. day,
4-
# day_of_month, hour_of_day) Validation and ScheduleLock::Validation modules.
5-
# It is not a standalone rule validation like the others.
3+
# This abstract validation class is used by the various "fixed-time" (e.g.
4+
# day, day_of_month, hour_of_day) Validation and ScheduleLock::Validation
5+
# modules. It is not a standalone rule validation module like the others.
66
#
7-
# Given the including Validation's defined +type+ field, it will lock
8-
# to the specified +value+ or else the corresponding time unit from the
9-
# schedule's start_time
7+
# Given the including Validation's defined +type+ field, it will lock to the
8+
# specified +value+ or else the corresponding time unit from the schedule's
9+
# start_time
1010
#
11-
module Validations::Lock
11+
class Validations::FixedValue
1212

1313
INTERVALS = {:min => 60, :sec => 60, :hour => 24, :month => 12, :wday => 7}
1414

lib/ice_cube/validations/hour_of_day.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def hour_of_day(*hours)
1414
self
1515
end
1616

17-
class Validation
18-
19-
include Validations::Lock
17+
class Validation < Validations::FixedValue
2018

2119
attr_reader :hour
2220
alias :value :hour

lib/ice_cube/validations/minute_of_hour.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ def minute_of_hour(*minutes)
1313
self
1414
end
1515

16-
class Validation
17-
18-
include Validations::Lock
16+
class Validation < Validations::FixedValue
1917

2018
attr_reader :minute
2119
alias :value :minute

lib/ice_cube/validations/month_of_year.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def month_of_year(*months)
1414
self
1515
end
1616

17-
class Validation
18-
19-
include Validations::Lock
17+
class Validation < Validations::FixedValue
2018

2119
attr_reader :month
2220
alias :value :month

lib/ice_cube/validations/schedule_lock.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def schedule_lock(*types)
1212
end
1313
end
1414

15-
class Validation
16-
17-
include Validations::Lock
15+
class Validation < Validations::FixedValue
1816

1917
attr_reader :type, :value
2018

lib/ice_cube/validations/second_of_minute.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ def second_of_minute(*seconds)
1313
self
1414
end
1515

16-
class Validation
17-
18-
include Validations::Lock
16+
class Validation < Validations::FixedValue
1917

2018
attr_reader :second
2119
alias :value :second

0 commit comments

Comments
 (0)