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 collapse
-
#primitive_inferrer ⇒ PrimitiveInferrer
readonly
private
PrimitiveInferrer used to get a list of primitive classes from configured type.
Attributes inherited from DSL
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
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 Attribute Details
#primitive_inferrer ⇒ PrimitiveInferrer (readonly)
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.
PrimitiveInferrer used to get a list of primitive classes from configured type
17 |
# File 'lib/dry/schema/macros/filled.rb', line 17 option :primitive_inferrer, default: proc { PrimitiveInferrer.new } |
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.
20 21 22 23 24 25 26 27 28 |
# File 'lib/dry/schema/macros/filled.rb', line 20 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
32 33 34 35 36 37 38 39 40 |
# File 'lib/dry/schema/macros/filled.rb', line 32 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.
54 55 56 |
# File 'lib/dry/schema/macros/filled.rb', line 54 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.
44 45 46 |
# File 'lib/dry/schema/macros/filled.rb', line 44 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.
49 50 51 |
# File 'lib/dry/schema/macros/filled.rb', line 49 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.
59 60 61 |
# File 'lib/dry/schema/macros/filled.rb', line 59 def schema_type schema_dsl.types[name] end |