Sha256: c3128ec548a76da006f9771a2214a47e7ff4955f72e6fca7e254280614d3496f

Contents?: true

Size: 1.36 KB

Versions: 26

Compression:

Stored size: 1.36 KB

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendEntityTypeDeclaration < ExtendModelTypeDeclaration
        class HashDesugarizer < 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)

            type_symbol = sugary_type_declaration[:type] || sugary_type_declaration["type"]
            return false unless type_symbol

            type_symbol = type_symbol.to_sym if type_symbol.is_a?(::String)

            return true if type_symbol == expected_type_symbol

            if type_symbol.is_a?(::Symbol) && type_registered?(type_symbol)
              type = Foobara.foobara_root_namespace.foobara_lookup_type(
                type_symbol, mode: Namespace::LookupMode::ABSOLUTE
              )

              type&.extends?(BuiltinTypes[expected_type_symbol])
            end
          end

          def expected_type_symbol
            :entity
          end

          def desugarize(sugary_type_declaration)
            Util.symbolize_keys(sugary_type_declaration)
          end

          def priority
            Priority::FIRST + 1
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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