Class: Alchemrest::Transforms::OutputType
- Inherits:
-
T::Struct
- Object
- T::Struct
- Alchemrest::Transforms::OutputType
- Defined in:
- lib/alchemrest/transforms/output_type.rb
Overview
A wrapper around other transforms that provides metadata about the return type of the transform. Note this does not do anything to actually enforce that return type, although we may want to change that in the future. It’s main purpose is to provide metadata we can use to inspect the schema of an ‘Alchemrest::Data` class.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.simple(sorbet_type) ⇒ Object
13 14 15 |
# File 'lib/alchemrest/transforms/output_type.rb', line 13 def self.simple(sorbet_type) new(sorbet_type:, constraints: []) end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/alchemrest/transforms/output_type.rb', line 29 def ==(other) sorbet_type == other.sorbet_type && constraints.to_set == other.constraints.to_set end |
#graph ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/alchemrest/transforms/output_type.rb', line 17 def graph graphs = graph_types.select { |type| has_graph?(type) }.map(&:graph) if graphs.size == 1 graphs.sole end end |
#with(args) ⇒ Object
25 26 27 |
# File 'lib/alchemrest/transforms/output_type.rb', line 25 def with(args) OutputType.new({ sorbet_type:, constraints: }.merge(args)) end |