lib/dry/schema/macros/dsl.rb in dry-schema-1.4.1 vs lib/dry/schema/macros/dsl.rb in dry-schema-1.4.2
- old
+ new
@@ -55,15 +55,16 @@
# required(:name).value { filled? & min_size?(2) }
#
# @return [Macros::Core]
#
# @api public
- def value(*predicates, **opts, &block)
+ def value(*predicates, &block)
append_macro(Macros::Value) do |macro|
- macro.call(*predicates, **opts, &block)
+ macro.call(*predicates, &block)
end
end
+ ruby2_keywords :value if respond_to?(:ruby2_keywords, true)
# Prepends `:filled?` predicate
#
# @example with a type spec
# required(:name).filled(:string)
@@ -72,15 +73,16 @@
# required(:name).filled(:string, format?: /\w+/)
#
# @return [Macros::Core]
#
# @api public
- def filled(*args, **opts, &block)
+ def filled(*args, &block)
append_macro(Macros::Filled) do |macro|
- macro.call(*args, **opts, &block)
+ macro.call(*args, &block)
end
end
+ ruby2_keywords :filled if respond_to?(:ruby2_keywords, true)
# Specify a nested hash without enforced `hash?` type-check
#
# This is a simpler building block than `hash` macro, use it
# when you want to provide `hash?` type-check with other rules
@@ -97,10 +99,11 @@
def schema(*args, &block)
append_macro(Macros::Schema) do |macro|
macro.call(*args, &block)
end
end
+ ruby2_keywords :schema if respond_to?(:ruby2_keywords, true)
# Specify a nested hash with enforced `hash?` type-check
#
# @example
# required(:tags).hash do
@@ -111,10 +114,11 @@
def hash(*args, &block)
append_macro(Macros::Hash) do |macro|
macro.call(*args, &block)
end
end
+ ruby2_keywords :hash if respond_to?(:ruby2_keywords, true)
# Specify predicates that should be applied to each element of an array
#
# This is a simpler building block than `array` macro, use it
# when you want to provide `array?` type-check with other rules
@@ -134,10 +138,11 @@
def each(*args, &block)
append_macro(Macros::Each) do |macro|
macro.value(*args, &block)
end
end
+ ruby2_keywords :each if respond_to?(:ruby2_keywords, true)
# Like `each` but sets `array?` type-check
#
# @example a list of strings
# required(:tags).array(:str?)
@@ -153,9 +158,10 @@
def array(*args, &block)
append_macro(Macros::Array) do |macro|
macro.value(*args, &block)
end
end
+ ruby2_keywords :array if respond_to?(:ruby2_keywords, true)
# Set type spec
#
# @example
# required(:name).type(:string).value(min_size?: 2)