Class: ActiveStorageValidations::Matchers::DimensionValidatorMatcher
Constant Summary
ASVTimeoutable::UNSET
Instance Method Summary
collapse
#initialize_timeoutable, #timeout
#failure_message_when_negated, #initialize_rspecable
#initialize_messageable, #with_message
#except_on, #initialize_except_onable
#initialize_contextable, #on
#allow_blank, #initialize_allow_blankable
Constructor Details
Returns a new instance of DimensionValidatorMatcher.
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 30
def initialize(attribute_name)
initialize_allow_blankable
initialize_contextable
initialize_except_onable
initialize_messageable
initialize_rspecable
initialize_timeoutable
@attribute_name = attribute_name
@width_min = @width_max = @height_min = @height_max = nil
end
|
Instance Method Details
#description ⇒ Object
41
42
43
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 41
def description
"validate the image dimensions of :#{@attribute_name}"
end
|
#failure_message ⇒ Object
45
46
47
48
49
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 45
def failure_message
message = [ "is expected to validate dimensions of :#{@attribute_name}" ]
build_failure_message(message)
message.join("\n")
end
|
#height(height) ⇒ Object
71
72
73
74
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 71
def height(height)
@height_min = @height_max = height
self
end
|
#height_between(range) ⇒ Object
86
87
88
89
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 86
def height_between(range)
@height_min, @height_max = range.first, range.last
self
end
|
#height_max(height) ⇒ Object
81
82
83
84
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 81
def height_max(height)
@height_max = height
self
end
|
#height_min(height) ⇒ Object
76
77
78
79
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 76
def height_min(height)
@height_min = height
self
end
|
#matches?(subject) ⇒ Boolean
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 91
def matches?(subject)
@subject = subject.is_a?(Class) ? subject.new : subject
is_a_valid_active_storage_attribute? &&
is_context_valid? &&
is_except_on_valid? &&
is_allowing_blank? &&
is_timeout_valid? &&
is_custom_message_valid? &&
width_not_smaller_than_min? &&
width_larger_than_min? &&
width_smaller_than_max? &&
width_not_larger_than_max? &&
width_equals? &&
height_not_smaller_than_min? &&
height_larger_than_min? &&
height_smaller_than_max? &&
height_not_larger_than_max? &&
height_equals?
end
|
#width(width) ⇒ Object
51
52
53
54
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 51
def width(width)
@width_min = @width_max = width
self
end
|
#width_between(range) ⇒ Object
66
67
68
69
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 66
def width_between(range)
@width_min, @width_max = range.first, range.last
self
end
|
#width_max(width) ⇒ Object
61
62
63
64
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 61
def width_max(width)
@width_max = width
self
end
|
#width_min(width) ⇒ Object
56
57
58
59
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 56
def width_min(width)
@width_min = width
self
end
|