Class: UseCase::GroupValidator

Inherits:
ValidatorParent show all
Defined in:
lib/usecasing/group_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValidatorParent

#call_failure

Class Method Details

.depends_all(*new_dependencies) ⇒ Object



17
18
19
# File 'lib/usecasing/group_validator.rb', line 17

def self.depends_all(*new_dependencies)
  group_dependencies.push(*new_dependencies)
end

Instance Method Details

#performObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/usecasing/group_validator.rb', line 5

def perform
  usecases_vs_results = {}

  self.class.group_dependencies.each do |usecase|
    usecases_vs_results[usecase.to_s] = usecase.perform(context_to_hash).success?
  end

  usecases_vs_results.each do |usecase_name, result|
    call_failure(:unprocessable_entity, usecase_name) unless result
  end
end