Class: PgTypes::TypeDefinition
- Inherits:
-
Object
- Object
- PgTypes::TypeDefinition
- Defined in:
- lib/pg_types/type_definition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(name, version:) ⇒ TypeDefinition
constructor
A new instance of TypeDefinition.
- #path ⇒ Object
- #to_sql ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/pg_types/type_definition.rb', line 5 def name @name end |
#version ⇒ Object (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_name ⇒ Object
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 |
#path ⇒ Object
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_sql ⇒ Object
12 13 14 |
# File 'lib/pg_types/type_definition.rb', line 12 def to_sql File.read(path) end |