Sha256: 797f03c28dcb7f3adee9fcca4cfe239a61860e57d1fcb73116d3bd54cc22f5a0

Contents?: true

Size: 1.04 KB

Versions: 26

Compression:

Stored size: 1.04 KB

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendRegisteredModelTypeDeclaration < ExtendRegisteredTypeDeclaration
        class HashDesugarizer < TypeDeclarations::Desugarizer
          def applicable?(sugary_type_declaration)
            return false unless sugary_type_declaration.is_a?(::Hash)

            type_symbol = sugary_type_declaration[:type]

            if 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
          end

          def expected_type_symbol
            :model
          end

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

          def priority
            Priority::HIGH
          end
        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/hash_desugarizer.rb
foobara-0.0.25 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.24 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.23 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.22 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.21 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.20 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.19 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.18 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.17 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.16 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.15 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.14 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.13 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.12 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.11 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.10 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.9 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.8 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb
foobara-0.0.7 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb