lib/dry/schema/dsl.rb
# A generic method for defining keys
#
# @param [Symbol] name The key name
# @param [Class] macro The macro sub-class (ie `Macros::Required` or any other `Macros::Key` subclass)
#
# @return [Macros::Key]
#
# @api public
A generic method for defining keys
A generic method for defining keys
def key(name, macro:, &block)
        raise ArgumentError, "Key +#{name}+ is not a symbol" unless name.is_a?(::Symbol)
        set_type(name, Types::Any.meta(default: true))
        macro = macro.new(
          name: name,
          compiler: compiler,
          schema_dsl: self,
          filter_schema_dsl: filter_schema_dsl
        )
        macro.value(&block) if block
        macros << macro
        macro
      end
def key ( name , macro : , & block ) raise ArgumentError , "Key +#{name}+ is not a symbol" unless name . is_a? ( :: Symbol ) set_type ( name , Types :: Any . meta ( default : true ) ) macro = macro . new ( name : name , compiler : compiler , schema_dsl : self , filter_schema_dsl : filter_schema_dsl ) macro . value ( & block ) if block macros << macro macro end
A generic method for defining keys
A generic method for defining keys
None
Macros::Key
name
<not_specific>
macro
<not_specific>
block
<not_specific>
<not_specific>
macro The macro sub-class
macro The macro sub - class
api
None