Class: ActiveStorageValidations::Matchers::ProcessableImageValidatorMatcher

Inherits:
Object
  • Object
show all
Includes:
ASVActiveStorageable, ASVAllowBlankable, ASVAttachable, ASVContextable, ASVMessageable, ASVRspecable, ASVValidatable
Defined in:
lib/active_storage_validations/matchers/processable_image_validator_matcher.rb

Instance Method Summary collapse

Methods included from ASVRspecable

#failure_message_when_negated, #initialize_rspecable

Methods included from ASVMessageable

#initialize_messageable, #with_message

Methods included from ASVContextable

#initialize_contextable, #on

Methods included from ASVAllowBlankable

#allow_blank, #initialize_allow_blankable

Constructor Details

#initialize(attribute_name) ⇒ ProcessableImageValidatorMatcher

Returns a new instance of ProcessableImageValidatorMatcher.



26
27
28
29
30
31
32
# File 'lib/active_storage_validations/matchers/processable_image_validator_matcher.rb', line 26

def initialize(attribute_name)
  initialize_allow_blankable
  initialize_contextable
  initialize_messageable
  initialize_rspecable
  @attribute_name = attribute_name
end

Instance Method Details

#descriptionObject



34
35
36
# File 'lib/active_storage_validations/matchers/processable_image_validator_matcher.rb', line 34

def description
  "validate that :#{@attribute_name} is a processable image"
end

#failure_messageObject



38
39
40
# File 'lib/active_storage_validations/matchers/processable_image_validator_matcher.rb', line 38

def failure_message
  "is expected to validate the processable image of :#{@attribute_name}"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
# File 'lib/active_storage_validations/matchers/processable_image_validator_matcher.rb', line 42

def matches?(subject)
  @subject = subject.is_a?(Class) ? subject.new : subject

  is_a_valid_active_storage_attribute? &&
  is_context_valid? &&
  is_custom_message_valid? &&
  is_valid_when_image_processable? &&
  is_invalid_when_image_not_processable?
end