Class: Farce::Internal::DryTypes::CollectionType
- Inherits:
-
Object
- Object
- Farce::Internal::DryTypes::CollectionType
- Includes:
- Dry::Types::Builder, Dry::Types::Type
- Defined in:
- lib/farce/integrations/dry_types.rb
Overview
A regular dry type that constructs a Farce value.
Direct Known Subclasses
Dry Types Integration collapse
-
#source ⇒ Dry::Types::Type
readonly
The dry type evaluated before Farce construction.
Dry Types Integration collapse
-
#call(input = ::Dry::Types::Undefined) {|partial| ... } ⇒ Object?
(also: #[])
Apply validation, coercion, and Farce construction to input.
-
#constrained? ⇒ Boolean
Report whether this type contains constraints.
-
#default? ⇒ Boolean
Report whether this is a default type.
-
#inspect ⇒ String
Return the wrapped dry type representation.
-
#meta(data = ::Dry::Types::Undefined) ⇒ BasicObject
Read or extend this type's metadata.
-
#name ⇒ String
Return the output type name.
-
#optional? ⇒ Boolean
Report whether this type accepts nil.
-
#primitive?(input) ⇒ Boolean
Test whether a value is accepted by the output type.
-
#pristine ⇒ CollectionType
Return a new type without source metadata.
-
#to_ast(meta: true) ⇒ Array
Return the dry-types abstract syntax tree.
-
#to_proc ⇒ Proc
Convert this type to a callable object.
-
#try(input) {|failure| ... } ⇒ Dry::Types::Result, Object
Try to construct a Farce value and return a dry-types result.
-
#valid?(input = ::Dry::Types::Undefined) ⇒ Boolean
(also: #===)
Test whether input can produce a valid Farce value.
-
#with(mode: UNDEFINED, scope: UNDEFINED, **source_options) ⇒ CollectionType
Return a new Farce type with different output or source options.
Instance Attribute Details
#source ⇒ Dry::Types::Type (readonly)
The dry type evaluated before Farce construction.
144 145 146 |
# File 'lib/farce/integrations/dry_types.rb', line 144 def source @source end |
Instance Method Details
#call(input = ::Dry::Types::Undefined) {|partial| ... } ⇒ Object? Also known as: []
Apply validation, coercion, and Farce construction to input.
176 |
# File 'lib/farce/integrations/dry_types.rb', line 176 def call(input = ::Dry::Types::Undefined, &) = @type.call(input, &) |
#constrained? ⇒ Boolean
Report whether this type contains constraints.
233 |
# File 'lib/farce/integrations/dry_types.rb', line 233 def constrained? = @type.constrained? |
#default? ⇒ Boolean
Report whether this is a default type.
229 |
# File 'lib/farce/integrations/dry_types.rb', line 229 def default? = @type.default? |
#inspect ⇒ String
Return the wrapped dry type representation.
263 |
# File 'lib/farce/integrations/dry_types.rb', line 263 def inspect = @type.inspect |
#meta ⇒ Hash #meta(data) ⇒ CollectionType
Read or extend this type's metadata.
276 277 278 279 280 |
# File 'lib/farce/integrations/dry_types.rb', line 276 def (data = ::Dry::Types::Undefined) return @type. if ::Dry::Types::Undefined.equal?(data) self.class.new(source.(data), kind:, configuration:) end |
#name ⇒ String
Return the output type name.
225 |
# File 'lib/farce/integrations/dry_types.rb', line 225 def name = @type.name |
#optional? ⇒ Boolean
Report whether this type accepts nil.
237 |
# File 'lib/farce/integrations/dry_types.rb', line 237 def optional? = @type.optional? |
#primitive?(input) ⇒ Boolean
Test whether a value is accepted by the output type.
216 |
# File 'lib/farce/integrations/dry_types.rb', line 216 def primitive?(input) = @type.primitive?(input) |
#pristine ⇒ CollectionType
Return a new type without source metadata.
284 |
# File 'lib/farce/integrations/dry_types.rb', line 284 def pristine = self.class.new(source.pristine, kind:, configuration:) |
#to_ast(meta: true) ⇒ Array
Return the dry-types abstract syntax tree.
255 |
# File 'lib/farce/integrations/dry_types.rb', line 255 def to_ast(meta: true) = @type.to_ast(meta:) |
#to_proc ⇒ Proc
Convert this type to a callable object.
259 |
# File 'lib/farce/integrations/dry_types.rb', line 259 def to_proc = proc { call(it) } |
#try(input) {|failure| ... } ⇒ Dry::Types::Result, Object
Try to construct a Farce value and return a dry-types result.
200 |
# File 'lib/farce/integrations/dry_types.rb', line 200 def try(input, &) = @type.try(input, &) |
#valid?(input = ::Dry::Types::Undefined) ⇒ Boolean Also known as: ===
Test whether input can produce a valid Farce value.
205 |
# File 'lib/farce/integrations/dry_types.rb', line 205 def valid?(input = ::Dry::Types::Undefined) = @type.valid?(input) |
#with(mode: UNDEFINED, scope: UNDEFINED, **source_options) ⇒ CollectionType
Return a new Farce type with different output or source options.
292 293 294 295 296 |
# File 'lib/farce/integrations/dry_types.rb', line 292 def with(mode: UNDEFINED, scope: UNDEFINED, **) configured = configuration.with(kind:, mode:, scope:) next_source = .empty? ? source : source.with(**) self.class.new(next_source, kind:, configuration: configured) end |