Sha256: ac8c1fbfc9e608cc7176597b9e83811f9c7fea08bf14bf30cca28d0795add43e

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

module UseCase
  
  class GroupValidator < Base

    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|
        failure(usecase_name, :failed) unless result
      end
    end

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


    protected ####################### PROTECTED #################
    
    def context_to_hash
      context.instance_variable_get('@values')
    end

    def self.group_dependencies
      @group_dependencies ||= []
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
usecasing_validations-0.5.4 lib/usecasing/group_validator.rb
usecasing_validations-0.5.3 lib/usecasing/group_validator.rb