Sha256: 68afd6bf0fb0fe22da0d19a621992be3636016774f487359d69374268bcbcfc7

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendArrayTypeDeclaration < ExtendAssociativeArrayTypeDeclaration
        class ElementTypeDeclarationDesugarizer < TypeDeclarations::Desugarizer
          def applicable?(sugary_type_declaration)
            return false unless sugary_type_declaration.is_a?(::Hash)
            return false unless Util.all_symbolizable_keys?(sugary_type_declaration)

            sugary_type_declaration = Util.symbolize_keys(sugary_type_declaration)

            return false unless sugary_type_declaration.key?(:type)

            type_symbol = sugary_type_declaration[:type]

            type_symbol == :array && sugary_type_declaration.key?(:element_type_declaration)
          end

          def desugarize(sugary_type_declaration)
            sugar = sugary_type_declaration[:element_type_declaration]

            handler = type_declaration_handler_for(sugar)
            strict = handler.desugarize(sugar)

            sugary_type_declaration[:element_type_declaration] = strict

            sugary_type_declaration
          end

          def priority
            Priority::LOW
          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_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.6 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.5 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.4 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.3 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.2 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb
foobara-0.0.1 projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb