Class: Dumbo::Type
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#typrelid ⇒ Object
Returns the value of attribute typrelid.
Attributes inherited from PgObject
Instance Method Summary collapse
Methods inherited from PgObject
#downgrade, #execute, identfied_by, #identify, #initialize, #upgrade
Constructor Details
This class inherits a constructor from Dumbo::PgObject
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/dumbo/type.rb', line 3 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/dumbo/type.rb', line 3 def type @type end |
#typrelid ⇒ Object
Returns the value of attribute typrelid.
3 4 5 |
# File 'lib/dumbo/type.rb', line 3 def typrelid @typrelid end |
Instance Method Details
#drop ⇒ Object
26 27 28 |
# File 'lib/dumbo/type.rb', line 26 def drop "DROP TYPE #{name};" end |
#get ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dumbo/type.rb', line 13 def get case type when 'c' CompositeType.new(oid) when 'b' BaseType.new(oid) when 'r' RangeType.new(oid) when 'e' EnumType.new(oid) end end |
#load_attributes ⇒ Object
6 7 8 9 10 11 |
# File 'lib/dumbo/type.rb', line 6 def load_attributes result = execute("SELECT typname, typtype, typrelid FROM pg_type WHERE oid = #{oid}").first @name = result['typname'] @type = result['typtype'] @typrelid = result['typrelid'] end |