Sha256: 04cdbaa75caee826e6b287a43aac3261dea382b9f8f26131b570a156d346f62e

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

require 'dry/schema/macros/dsl'

module Dry
  module Schema
    module Macros
      # Macro used to specify predicates for each element of an array
      #
      # @api public
      class Each < DSL
        # @api private
        def value(*args, **opts)
          extract_type_spec(*args, set_type: false) do |*predicates, type_spec:|
            type(schema_dsl.array[type_spec]) if type_spec

            super(*predicates, type_spec: type_spec, **opts)
          end
        end

        # @api private
        def to_ast(*)
          [:each, trace.to_ast]
        end
        alias_method :ast, :to_ast
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-schema-0.6.0 lib/dry/schema/macros/each.rb
dry-schema-0.5.1 lib/dry/schema/macros/each.rb
dry-schema-0.5.0 lib/dry/schema/macros/each.rb