Class: Dry::Validation::Rust::Schema::PredicateBlock Private
- Inherits:
-
Object
- Object
- Dry::Validation::Rust::Schema::PredicateBlock
- Defined in:
- lib/dry/validation/rust/schema/predicate_block.rb
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.
Constant Summary collapse
- ARITY_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ gt: 1, gteq: 1, lt: 1, lteq: 1, min_size: 1, max_size: 1, size: 1, format: 1, included_in: 1, excluded_from: 1, eql: 1, not_eql: 1, odd: 0, even: 0 }.freeze
Instance Method Summary collapse
-
#initialize(definition) ⇒ PredicateBlock
constructor
private
A new instance of PredicateBlock.
- #method_missing(name, *args, **kwargs, &block) ⇒ Object private
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Constructor Details
#initialize(definition) ⇒ PredicateBlock
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.
Returns a new instance of PredicateBlock.
15 16 17 |
# File 'lib/dry/validation/rust/schema/predicate_block.rb', line 15 def initialize(definition) @definition = definition end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dry/validation/rust/schema/predicate_block.rb', line 19 def method_missing(name, *args, **kwargs, &block) if name.to_s.end_with?('?') && block.nil? validate_arity(name, args, kwargs) argument = if kwargs.empty? args.length <= 1 ? args.first : args else kwargs end @definition.add_predicate(name, argument: argument.nil? || argument) return self end raise UnsupportedFeatureError, "unsupported predicate composition expression: #{name.inspect}" end |
Instance Method Details
#respond_to_missing?(name, 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.
35 36 37 |
# File 'lib/dry/validation/rust/schema/predicate_block.rb', line 35 def respond_to_missing?(name, include_private = false) name.to_s.end_with?('?') || super end |