Class: Dry::Schema::Macros::Value Private
- Defined in:
- lib/dry/schema/macros/value.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A macro used for specifying predicates to be applied to values from a hash
Instance Attribute Summary
Attributes inherited from DSL
Instance Method Summary collapse
- #call(*predicates, **opts, &block) ⇒ Object private
- #respond_to_missing?(meth, include_private = false) ⇒ Boolean private
Methods inherited from DSL
#array, #each, #filled, #hash, #schema, #type, #value
Methods inherited from Core
#new, #operation, #to_ast, #to_rule
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 55 56 |
# File 'lib/dry/schema/macros/value.rb', line 50 def method_missing(meth, *args, &block) if meth.to_s.end_with?(QUESTION_MARK) trace.__send__(meth, *args, &block) else super end end |
Instance Method Details
#call(*predicates, **opts, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dry/schema/macros/value.rb', line 13 def call(*predicates, **opts, &block) schema = predicates.detect { |predicate| predicate.is_a?(Processor) } if schema current_type = schema_dsl.types[name] updated_type = if current_type.respond_to?(:of) current_type.of(schema.type_schema) else schema.type_schema end schema_dsl.set_type(name, updated_type) end trace.evaluate(*predicates, **opts) trace.append(new(chain: false).instance_exec(&block)) if block if trace.captures.empty? raise ArgumentError, 'wrong number of arguments (given 0, expected at least 1)' end type_spec = opts[:type_spec] each(type_spec.type.member) if type_spec.respond_to?(:member) self end |
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/dry/schema/macros/value.rb', line 43 def respond_to_missing?(meth, include_private = false) super || meth.to_s.end_with?(QUESTION_MARK) end |