Sha256: 1edfeee378267d2b505e92f1f2d1b6da2be40954c4ed3ef24c9397c3cf8ae19c

Contents?: true

Size: 417 Bytes

Versions: 7

Compression:

Stored size: 417 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Schema
    module Macros
      #
      # Macros DSL for options with default values
      # (see https://github.com/dry-rb/dry-schema/issues/70)
      #
      class DSL
        def default(value)
          schema_dsl.before(:rule_applier) do |result|
            result.update(name => value) unless result[name]
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/schemas/macros.rb
mihari-6.2.0 lib/mihari/schemas/macros.rb
mihari-6.1.0 lib/mihari/schemas/macros.rb
mihari-6.0.0 lib/mihari/schemas/macros.rb
mihari-5.7.2 lib/mihari/schemas/macros.rb
mihari-5.7.1 lib/mihari/schemas/macros.rb
mihari-5.7.0 lib/mihari/schemas/macros.rb