Class: Dry::Schema::Macros::Filled Private
- Defined in:
- lib/dry/schema/macros/filled.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.
Macro used to prepend ‘:filled?` predicate
Instance Attribute Summary
Attributes inherited from DSL
#chain, #predicate_inferrer, #primitive_inferrer
Instance Method Summary collapse
- #call(*predicates, **opts, &block) ⇒ Object private
-
#ensure_valid_predicates(predicates) ⇒ Object
private
rubocop:disable Style/GuardClause.
- #expected_primitives ⇒ Object private
- #filter_empty_string? ⇒ Boolean private
- #processor_config ⇒ Object private
- #schema_type ⇒ Object private
Methods inherited from Value
#array_type?, #build_array_type, #respond_to_missing?
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 in the class Dry::Schema::Macros::Value
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.
14 15 16 17 18 19 20 21 22 |
# File 'lib/dry/schema/macros/filled.rb', line 14 def call(*predicates, **opts, &block) ensure_valid_predicates(predicates) if opts[:type_spec] && !filter_empty_string? value(predicates[0], :filled?, *predicates[1..predicates.size - 1], **opts, &block) else value(:filled?, *predicates, **opts, &block) end end |
#ensure_valid_predicates(predicates) ⇒ 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.
rubocop:disable Style/GuardClause
26 27 28 29 30 31 32 33 34 |
# File 'lib/dry/schema/macros/filled.rb', line 26 def ensure_valid_predicates(predicates) if predicates.include?(:empty?) raise ::Dry::Schema::InvalidSchemaError, 'Using filled with empty? predicate is invalid' end if predicates.include?(:filled?) raise ::Dry::Schema::InvalidSchemaError, 'Using filled with filled? is redundant' end end |
#expected_primitives ⇒ 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.
48 49 50 |
# File 'lib/dry/schema/macros/filled.rb', line 48 def expected_primitives primitive_inferrer[schema_type] end |
#filter_empty_string? ⇒ 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.
38 39 40 |
# File 'lib/dry/schema/macros/filled.rb', line 38 def filter_empty_string? !expected_primitives.include?(NilClass) && processor_config.filter_empty_string end |
#processor_config ⇒ 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.
43 44 45 |
# File 'lib/dry/schema/macros/filled.rb', line 43 def processor_config schema_dsl.processor_type.config end |
#schema_type ⇒ 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.
53 54 55 |
# File 'lib/dry/schema/macros/filled.rb', line 53 def schema_type schema_dsl.types[name] end |