Class: PgGraph::Type::ArrayType

Inherits:
Type show all
Defined in:
lib/pg_graph/type/type.rb

Direct Known Subclasses

TableType

Constant Summary collapse

DEFAULT_MAX_DIMENSIONS =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#array_type, #tuple?, #value?

Methods inherited from Node

#dump, #guid, #inspect, #inspect_inner

Constructor Details

#initialize(schema, name, element_type, dimensions = 1) ⇒ ArrayType

Returns a new instance of ArrayType.



363
364
365
366
367
368
369
370
# File 'lib/pg_graph/type/type.rb', line 363

def initialize(schema, name, element_type, dimensions = 1)
  constrain element_type, Type
  self.class < TableObject or !element_type.is_a?(TableObject) or raise "Illegal element type"
  dimensions <= ArrayType.max_dimensions or raise Error, "Array dimension overflow"
  super(schema, name || PgGraph.inflector.type2array(element_type.name))
  @element_type = element_type
  @dimensions = dimensions
end

Instance Attribute Details

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



358
359
360
# File 'lib/pg_graph/type/type.rb', line 358

def dimensions
  @dimensions
end

#element_typeObject (readonly)

Returns the value of attribute element_type.



357
358
359
# File 'lib/pg_graph/type/type.rb', line 357

def element_type
  @element_type
end

Instance Method Details

#array?Boolean

Returns:

  • (Boolean)


361
# File 'lib/pg_graph/type/type.rb', line 361

def array?() true end

#identifierObject



372
373
374
# File 'lib/pg_graph/type/type.rb', line 372

def identifier
  "[#{element_type.identifier}]"
end

#rankObject



360
# File 'lib/pg_graph/type/type.rb', line 360

def rank() 2 end

#schema_identifierObject



376
377
378
# File 'lib/pg_graph/type/type.rb', line 376

def schema_identifier
  "[#{element_type.schema_identifier}]"
end