Class: Dry::Schema::Macros::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/mihari/schemas/macros.rb

Overview

Macros DSL for options with default values (see github.com/dry-rb/dry-schema/issues/70)

Instance Method Summary collapse

Instance Method Details

#default(value) ⇒ Object



11
12
13
14
15
# File 'lib/mihari/schemas/macros.rb', line 11

def default(value)
  schema_dsl.before(:rule_applier) do |result|
    result.update(name => value) if result.output && !result[name]
  end
end