Module: SimpleImagesDownloader::Validatable

Included in:
Dispenser, Downloader, SourceFile
Defined in:
lib/simple_images_downloader/validatable.rb,
lib/simple_images_downloader/validatable/validator.rb,
lib/simple_images_downloader/validatable/mime_type_validator.rb,
lib/simple_images_downloader/validatable/destination_validator.rb,
lib/simple_images_downloader/validatable/file_persistance_validator.rb,
lib/simple_images_downloader/validatable/file_accessibility_validator.rb

Overview

Validatable module Responsible for validating the object using array of validators

Examples:

class SourceFile
  include Validatable

  def initialize(path, validators = [FilePersistanceValidator.new, FileAccessibilityValidator.new])
    @path       = path
    @validators = validators
  end

  def each_line(&block)
    validate!({ path: @path })
    # ...
  end
end

Defined Under Namespace

Classes: DestinationValidator, FileAccessibilityValidator, FilePersistanceValidator, MimeTypeValidator, Validator

Instance Method Summary collapse

Instance Method Details

#validate!(value) ⇒ Object

Parameters:

  • value (Object)

    value to validate

Raises:

  • (Errors::<Particular>Error)

    if value is not valid



24
25
26
# File 'lib/simple_images_downloader/validatable.rb', line 24

def validate!(value)
  (@validators ||= []).each { |validator| validator.validate(value) }
end