Sha256: 582d4c80ba802808e45a41130f3d9ad05d88f79a4049a0994f3b37b7876416c3

Contents?: true

Size: 619 Bytes

Versions: 4

Compression:

Stored size: 619 Bytes

Contents

module UseCase
  
  class Validator < Base

    include UseCaseValidations
    
    def perform
      targets = [*target]

      if target.nil?
        all_validations_green = false

      elsif targets.empty?
        all_validations_green = true
        
      else
        all_validations_green = targets.map do |object_to_validate|
          if Helpers._marked_for_destruction?(object_to_validate)
            true
          else
            valid?(object_to_validate)
          end
        end.all?
      end

      failure(self.class.to_s.downcase.to_sym, :failed) unless all_validations_green
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
usecasing_validations-0.5.4 lib/usecasing/validator.rb
usecasing_validations-0.5.3 lib/usecasing/validator.rb
usecasing_validations-0.5.1 lib/usecasing/validator.rb
usecasing_validations-0.5.0 lib/usecasing/validator.rb