Sha256: 844d810e77ba1bae108242e9acf360498f14e3a5d42be0c14191d3e7f78d319b

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

# frozen_string_literal: true

require 'dry/schema/key'
require 'dry/schema/key_map'

module Dry
  module Schema
    # @api private
    #
    # TODO: this should be moved to dry-schema at some point
    class Key
      # @api private
      def to_dot_notation
        [name.to_s]
      end

      # @api private
      class Hash < Key
        # @api private
        def to_dot_notation
          [name].product(members.map(&:to_dot_notation).flatten(1)).map { |e| e.join(DOT) }
        end
      end
    end

    # @api private
    class KeyMap
      # @api private
      def to_dot_notation
        @to_dot_notation ||= map(&:to_dot_notation).flatten
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-1.2.1 lib/dry/validation/schema_ext.rb
dry-validation-1.2.0 lib/dry/validation/schema_ext.rb