Sha256: d92ac379d5da11bd725698d1850883826445ea9f584d6f2f1e44621089187e3f

Contents?: true

Size: 895 Bytes

Versions: 26

Compression:

Stored size: 895 Bytes

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      # Why doesn't this inherit from ExtendModelTypeDeclaration
      class ExtendRegisteredModelTypeDeclaration < ExtendRegisteredTypeDeclaration
        def applicable?(sugary_type_declaration)
          strict_type_declaration = desugarize(sugary_type_declaration)

          if strict_type_declaration.is_a?(::Hash) && strict_type_declaration.key?(:type)
            type_symbol = strict_type_declaration[:type]

            return false if type_symbol == expected_type_symbol

            if type_registered?(type_symbol)
              type = type_for_declaration(type_symbol)
              type.extends?(BuiltinTypes[expected_type_symbol])
            end
          end
        end

        def expected_type_symbol
          :model
        end

        def priority
          super - 1
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.25 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.24 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.23 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.22 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.21 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.20 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.19 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.18 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.17 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.16 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.15 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.14 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.13 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.12 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.11 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.10 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.9 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.8 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb
foobara-0.0.7 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb