Class: ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher
Instance Method Summary
collapse
Methods included from Rspecable
#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.
24
25
26
27
28
29
30
31
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 24
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
41
42
43
44
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 41
def allowing(*aspect_ratios)
@allowed_aspect_ratios = aspect_ratios.flatten
self
end
|
#description ⇒ Object
33
34
35
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 33
def description
"validate the aspect ratios allowed on :#{@attribute_name}."
end
|
#failure_message ⇒ Object
37
38
39
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 37
def failure_message
"is expected to validate aspect ratio of :#{@attribute_name}"
end
|
#matches?(subject) ⇒ Boolean
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 51
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
46
47
48
49
|
# File 'lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb', line 46
def rejecting(*aspect_ratios)
@rejected_aspect_ratios = aspect_ratios.flatten
self
end
|