Class: PgTypes::TypeDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_types/type_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version:) ⇒ TypeDefinition

Returns a new instance of TypeDefinition.



7
8
9
10
# File 'lib/pg_types/type_definition.rb', line 7

def initialize(name, version:)
  @name = name
  @version = version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/pg_types/type_definition.rb', line 5

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/pg_types/type_definition.rb', line 5

def version
  @version
end

Instance Method Details

#full_nameObject



20
21
22
# File 'lib/pg_types/type_definition.rb', line 20

def full_name
  name.to_s.include?(".") ? name.to_s : "public.#{name}"
end

#pathObject



16
17
18
# File 'lib/pg_types/type_definition.rb', line 16

def path
  Rails.root.join("db", "types", "#{name}_v#{version}.sql").to_s
end

#to_sqlObject



12
13
14
# File 'lib/pg_types/type_definition.rb', line 12

def to_sql
  File.read(path)
end