Class: Dragnet::Validators::Entities::RepoValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/dragnet/validators/entities/repo_validator.rb

Overview

Validates a Dragnet::Repo object, by checking its attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ RepoValidator

Returns a new instance of RepoValidator.

Parameters:

  • repo (Dragnet::Repo)

    An instance of Dragnet::Repo to validate.



15
16
17
# File 'lib/dragnet/validators/entities/repo_validator.rb', line 15

def initialize(repo)
  @repo = repo
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



12
13
14
# File 'lib/dragnet/validators/entities/repo_validator.rb', line 12

def repo
  @repo
end

Instance Method Details

#validateObject

Validates the instance of the Dragnet::Repo object by checking each of its attributes.

Raises:



23
24
25
26
27
# File 'lib/dragnet/validators/entities/repo_validator.rb', line 23

def validate
  Dragnet::Validators::Fields::SHA1Validator.new.validate('repos[sha1]', repo.sha1)
  Dragnet::Validators::Fields::PathValidator.new.validate('repos[path]', repo.path)
  repo.files = Dragnet::Validators::Fields::FilesValidator.new.validate('repos[files]', repo.files)
end