Module: Dry::Tuple::StructClassInterface
Overview
Extracted due to make it possible to use this feature within Struct classes.
Instance Method Summary
collapse
#call_safe, #call_unsafe, #new_from_tuple
Instance Method Details
#auto_tuple(*keys) ⇒ Object
138
139
140
141
142
|
# File 'lib/dry/tuple.rb', line 138
def auto_tuple(*keys)
keys_order(keys_order | keys)
index = schema.keys.map { |t| [t.name, t.type] }.to_h
tuple Dry::Types::Tuple.build_unsplat(index.values_at(*keys_order))
end
|
#coerce_tuple(input) ⇒ Object
144
145
146
|
# File 'lib/dry/tuple.rb', line 144
def coerce_tuple(input)
keys_order.zip(input).to_h
end
|
#try(input, &block) ⇒ Object
130
131
132
133
134
135
136
|
# File 'lib/dry/tuple.rb', line 130
def try(input, &block)
if input.is_a?(::Array)
@tuple.try(input, &block)
else
super(input, &block)
end
end
|