Extract method and clear up what's happening.

This commit is contained in:
Gabe Berke-Williams 2012-05-11 10:28:38 -04:00
parent 5542991b6e
commit 18f668051e
1 changed files with 9 additions and 5 deletions

View File

@ -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 ||