Class: DatabaseConsistency::Databases::Types::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/database_consistency/databases/types/base.rb

Overview

Base wrapper for database types

Direct Known Subclasses

Sqlite

Constant Summary collapse

NUMERIC_TYPES =
%w[bigserial serial bigint integer smallint].freeze
COVERED_TYPES =
{
  'bigint' => %w[integer bigint],
  'integer' => %w[integer smallint]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Base

Returns a new instance of Base.

Parameters:

  • type (String)


18
19
20
# File 'lib/database_consistency/databases/types/base.rb', line 18

def initialize(type)
  @type = type.downcase
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/database_consistency/databases/types/base.rb', line 8

def type
  @type
end

Instance Method Details

#convertString

Returns:

  • (String)


23
24
25
# File 'lib/database_consistency/databases/types/base.rb', line 23

def convert
  type
end

#cover?(other_type) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


34
35
36
# File 'lib/database_consistency/databases/types/base.rb', line 34

def cover?(other_type)
  (COVERED_TYPES[convert] || [convert]).include?(other_type.convert)
end

#numeric?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/database_consistency/databases/types/base.rb', line 27

def numeric?
  NUMERIC_TYPES.include?(convert)
end