Class: ActiveStorageValidations::Matchers::LimitValidatorMatcher
- Inherits:
-
Object
- Object
- ActiveStorageValidations::Matchers::LimitValidatorMatcher
- Includes:
- ASVActiveStorageable, ASVAllowBlankable, ASVAttachable, ASVContextable, ASVExceptOnable, ASVMessageable, ASVRspecable, ASVValidatable
- Defined in:
- lib/active_storage_validations/matchers/limit_validator_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(attribute_name) ⇒ LimitValidatorMatcher
constructor
A new instance of LimitValidatorMatcher.
- #matches?(subject) ⇒ Boolean
- #max(count) ⇒ Object
- #min(count) ⇒ Object
Methods included from ASVRspecable
#failure_message_when_negated, #initialize_rspecable
Methods included from ASVMessageable
#initialize_messageable, #with_message
Methods included from ASVExceptOnable
#except_on, #initialize_except_onable
Methods included from ASVContextable
Methods included from ASVAllowBlankable
#allow_blank, #initialize_allow_blankable
Constructor Details
#initialize(attribute_name) ⇒ LimitValidatorMatcher
Returns a new instance of LimitValidatorMatcher.
28 29 30 31 32 33 34 35 36 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 28 def initialize(attribute_name) initialize_allow_blankable initialize_contextable initialize_except_onable initialize_rspecable @attribute_name = attribute_name @min = @max = nil end |
Instance Method Details
#description ⇒ Object
38 39 40 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 38 def description "validate the limit files of :#{@attribute_name}" end |
#failure_message ⇒ Object
42 43 44 45 46 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 42 def = [ "is expected to validate limit file of :#{@attribute_name}" ] () .join("\n") end |
#matches?(subject) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 58 def matches?(subject) @subject = subject.is_a?(Class) ? subject.new : subject is_a_valid_active_storage_attribute? && is_context_valid? && is_except_on_valid? && && file_count_not_smaller_than_min? && file_count_equal_min? && file_count_larger_than_min? && file_count_smaller_than_max? && file_count_equal_max? && file_count_not_larger_than_max? end |
#max(count) ⇒ Object
53 54 55 56 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 53 def max(count) @max = count self end |
#min(count) ⇒ Object
48 49 50 51 |
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 48 def min(count) @min = count self end |