Class: ActiveStorageValidations::Matchers::BaseComparisonValidatorMatcher
Instance Method Summary
collapse
#description, #failure_message, #failure_message_when_negated, #initialize_rspecable
#initialize_messageable, #with_message
#initialize_contextable, #on
#allow_blank, #initialize_allow_blankable
Constructor Details
Returns a new instance of BaseComparisonValidatorMatcher.
27
28
29
30
31
32
33
34
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 27
def initialize(attribute_name)
initialize_allow_blankable
initialize_contextable
initialize_messageable
initialize_rspecable
@attribute_name = attribute_name
@min = @max = nil
end
|
Instance Method Details
#between(range) ⇒ Object
56
57
58
59
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 56
def between(range)
@min, @max = range.first, range.last
self
end
|
#greater_than(value) ⇒ Object
46
47
48
49
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 46
def greater_than(value)
@min = value + smallest_measurement
self
end
|
#greater_than_or_equal_to(value) ⇒ Object
51
52
53
54
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 51
def greater_than_or_equal_to(value)
@min = value
self
end
|
#less_than(value) ⇒ Object
36
37
38
39
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 36
def less_than(value)
@max = value - smallest_measurement
self
end
|
#less_than_or_equal_to(value) ⇒ Object
41
42
43
44
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 41
def less_than_or_equal_to(value)
@max = value
self
end
|
#matches?(subject) ⇒ Boolean
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/active_storage_validations/matchers/base_comparison_validator_matcher.rb', line 61
def matches?(subject)
@subject = subject.is_a?(Class) ? subject.new : subject
is_a_valid_active_storage_attribute? &&
is_context_valid? &&
is_allowing_blank? &&
is_custom_message_valid? &&
not_lower_than_min? &&
higher_than_min? &&
lower_than_max? &&
not_higher_than_max?
end
|