Sha256: 656875eb1a50813f6bfda5f11db1793c6bc29e82f2472626788fd69c53002dc8

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

Foobara.require_project_file("type_declarations", "desugarizer")
Foobara.require_project_file("type_declarations", "handlers/extend_associative_array_type_declaration")

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendTupleTypeDeclaration < ExtendAssociativeArrayTypeDeclaration
        # TODO: make a quick way to convert a couple simple procs into a transformer
        class ArrayDesugarizer < TypeDeclarations::Desugarizer
          def applicable?(sugary_type_declaration)
            sugary_type_declaration.is_a?(::Array) && sugary_type_declaration.size > 1
          end

          def desugarize(sugary_type_declaration)
            element_type_declarations = sugary_type_declaration.map do |element_type_declaration|
              handler = type_declaration_handler_for(element_type_declaration)

              handler.desugarize(element_type_declaration)
            end

            {
              type: :tuple,
              element_type_declarations:
            }
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.6 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.5 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.4 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.3 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.2 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
foobara-0.0.1 projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb