Extract method and clear up what's happening.
This commit is contained in:
parent
5542991b6e
commit
18f668051e
|
@ -93,11 +93,7 @@ module Shoulda # :nodoc:
|
|||
def matches?(subject)
|
||||
super(subject)
|
||||
translate_messages!
|
||||
disallows_lower_length? &&
|
||||
allows_minimum_length? &&
|
||||
((@options[:minimum] == @options[:maximum]) ||
|
||||
(disallows_higher_length? &&
|
||||
allows_maximum_length?))
|
||||
lower_bound_matches? && upper_bound_matches?
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -118,6 +114,14 @@ module Shoulda # :nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
def lower_bound_matches?
|
||||
disallows_lower_length? && allows_minimum_length?
|
||||
end
|
||||
|
||||
def upper_bound_matches?
|
||||
disallows_higher_length? && allows_maximum_length?
|
||||
end
|
||||
|
||||
def disallows_lower_length?
|
||||
if @options.key?(:minimum)
|
||||
@options[:minimum] == 0 ||
|
||||
|
|
Loading…
Reference in New Issue