Class: PgGraph::Type::SimpleColumn

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

Overview

Note that this includes array columns (for now)

Instance Attribute Summary collapse

Attributes inherited from Column

#postgres_column

Attributes inherited from Field

#type

Instance Method Summary collapse

Methods inherited from Column

#dump, #dump_type, #generated?, #identity?, #kind?, #nullable?, #primary_key?, #readonly?, #reference?, #unique?

Methods included from TableObject

#record_type, #table, #table_type

Methods inherited from Field

#identifier, #schema_identifier

Methods inherited from Node

#dump, #guid, #identifier, #inspect, #inspect_inner, #schema_identifier

Constructor Details

#initialize(record_type, name, postgres_column, type, **opts) ⇒ SimpleColumn

Returns a new instance of SimpleColumn.



491
492
493
494
495
496
# File 'lib/pg_graph/type/type.rb', line 491

def initialize(record_type, name, postgres_column, type, **opts)
  constrain type, Type
  !type.is_a?(TableObject) or raise "Illegal field type: #{type.class}"
  @ordinal = opts.delete(:ordinal)
  super
end

Instance Attribute Details

#ordinalObject (readonly)

Ordinal of column in the database



487
488
489
# File 'lib/pg_graph/type/type.rb', line 487

def ordinal
  @ordinal
end

Instance Method Details

#literal?(text) ⇒ Boolean

Return true if the ruby literal match the column type

Returns:

  • (Boolean)


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

def literal?(text) text.is_a?(ruby_class) end