Module: Dry::Tuple

Defined in:
lib/dry/tuple.rb

Overview

The namespace contains mixins for class decoration with tuple type. The interfaces provide a way to use a tuple in constructors to match proper class by input. The behaviour is similar to the one provided by ‘Dry::Struct::ClassInterface` and allows to combine classes into sums but with positional input validation & coercion.

Examples:

Splat input

class Example
  extend Dry::Tuple::ClassInterface
  tuple Types.Tuple(Types::Integer, Types::String)

  def initializer(a1, a2)
    # ...
  end

  def self.new_from_tuple(input)
    new(*input)
  end
end

Defined Under Namespace

Modules: ClassDecorator, ClassInterface, HookExtendObject, StructClassInterface