Sha256: 66d533224aa11642a3c481af7b4bdb893330fffa711ddbd6e632a9e0034b328a

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendDetachedEntityTypeDeclaration < ExtendModelTypeDeclaration
        class ValidatePrimaryKeyIsSymbol < TypeDeclarations::TypeDeclarationValidator
          class PrimaryKeyNotSymbolError < TypeDeclarationError
            class << self
              def context_type_declaration
                {
                  primary_key: :duck
                }
              end
            end
          end

          def applicable?(strict_type_declaration)
            strict_type_declaration.key?(:primary_key)
          end

          def validation_errors(strict_type_declaration)
            primary_key = strict_type_declaration[:primary_key]
            unless primary_key.is_a?(::Symbol)
              build_error(
                message: "Expected #{primary_key} to be a symbol but it was a #{primary_key.class}",
                context: {
                  primary_key:
                }
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foobara-0.0.38 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.37 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.36 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.35 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.34 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.33 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.32 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
foobara-0.0.31 projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb