Sha256: 063348763096d28f09df98f7c622efd16208ff2001a73788956d26da706bbfbc

Contents?: true

Size: 1.14 KB

Versions: 26

Compression:

Stored size: 1.14 KB

Contents

module Foobara
  module BuiltinTypes
    module Array
      module SupportedProcessors
        class ElementTypeDeclaration < TypeDeclarations::ElementProcessor
          def element_type
            @element_type ||= type_for_declaration(element_type_declaration)
          end

          def process_value(array)
            errors = []

            array.each.with_index do |element, index|
              element_outcome = element_type.process_value(element)

              if element_outcome.success?
                array[index] = element_outcome.result
              else
                element_outcome.each_error do |error|
                  error.prepend_path!(index)

                  errors << error
                end
              end
            end

            Outcome.new(result: array, errors:)
          end

          def possible_errors
            super + element_type.possible_errors.map do |possible_error|
                      possible_error = possible_error.dup
                      possible_error.prepend_path!(:"#")
                      possible_error
                    end
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.25 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.24 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.23 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.22 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.21 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.20 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.19 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.18 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.17 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.16 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.15 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.14 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.13 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.12 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.11 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.10 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.9 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.8 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb
foobara-0.0.7 projects/builtin_types/src/array/supported_processors/element_type_declaration.rb