Class: Farce::Internal::DryTypes::MapType
- Inherits:
-
CollectionType
- Object
- CollectionType
- Farce::Internal::DryTypes::MapType
- Defined in:
- lib/farce/integrations/dry_types.rb
Overview
A Map type that supports dry-types homogeneous maps and schemas.
Instance Attribute Summary
Attributes inherited from CollectionType
Dry Types Integration collapse
-
#map(key_type, value_type) ⇒ MapType
Apply dry types to every key and value before Farce construction.
-
#schema ⇒ BasicObject
Define or extend fixed keys and their dry types before Farce construction.
-
#strict(strict = true) ⇒ MapType
Return a schema that rejects unknown keys.
-
#with_key_transform(transform = nil) {|key| ... } ⇒ MapType
Transform input keys before schema lookup.
-
#with_type_transform(transform = nil) {|type| ... } ⇒ MapType
Transform schema key types when defining a schema.
Methods inherited from CollectionType
#call, #constrained?, #default?, #inspect, #meta, #name, #optional?, #primitive?, #pristine, #to_ast, #to_proc, #try, #valid?, #with
Instance Method Details
#map(key_type, value_type) ⇒ MapType
Apply dry types to every key and value before Farce construction.
340 341 342 343 344 |
# File 'lib/farce/integrations/dry_types.rb', line 340 def map(key_type, value_type) typed = DryTypes.collection_source(source).map(key_type, value_type) typed = DryTypes.restore_optional_source(source, typed) self.class.new(typed, kind:, configuration:) end |
#schema(keys_or_map, meta = {}) ⇒ MapType #schema(keys_or_map) ⇒ MapType
Define or extend fixed keys and their dry types before Farce construction.
356 357 358 359 360 |
# File 'lib/farce/integrations/dry_types.rb', line 356 def schema(...) typed = DryTypes.collection_source(source).schema(...) typed = DryTypes.restore_optional_source(source, typed) self.class.new(typed, kind:, configuration:) end |
#strict(strict = true) ⇒ MapType
Return a schema that rejects unknown keys.
365 |
# File 'lib/farce/integrations/dry_types.rb', line 365 def strict(strict = true) = rebuild_map_source(:strict, strict) # rubocop:disable Style/OptionalBooleanParameter |
#with_key_transform(transform = nil) {|key| ... } ⇒ MapType
Transform input keys before schema lookup.
373 |
# File 'lib/farce/integrations/dry_types.rb', line 373 def with_key_transform(transform = nil, &) = rebuild_map_source(:with_key_transform, transform, &) |
#with_type_transform(transform = nil) {|type| ... } ⇒ MapType
Transform schema key types when defining a schema.
381 |
# File 'lib/farce/integrations/dry_types.rb', line 381 def with_type_transform(transform = nil, &) = rebuild_map_source(:with_type_transform, transform, &) |