Class: ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher
Instance Method Summary
collapse
#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 AspectRatioValidatorMatcher.
26
27
28
29
30
31
32
33
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 26
def initialize(attribute_name)
initialize_allow_blankable
initialize_contextable
initialize_messageable
initialize_rspecable
@attribute_name = attribute_name
@allowed_aspect_ratios = @rejected_aspect_ratios = []
end
|
Instance Method Details
#allowing(*aspect_ratios) ⇒ Object
43
44
45
46
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 43
def allowing(*aspect_ratios)
@allowed_aspect_ratios = aspect_ratios.flatten
self
end
|
#description ⇒ Object
35
36
37
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 35
def description
"validate the aspect ratios allowed on :#{@attribute_name}."
end
|
#failure_message ⇒ Object
39
40
41
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 39
def failure_message
"is expected to validate aspect ratio of :#{@attribute_name}"
end
|
#matches?(subject) ⇒ Boolean
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 53
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? &&
all_allowed_aspect_ratios_allowed? &&
all_rejected_aspect_ratios_rejected?
end
|
#rejecting(*aspect_ratios) ⇒ Object
48
49
50
51
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 48
def rejecting(*aspect_ratios)
@rejected_aspect_ratios = aspect_ratios.flatten
self
end
|