Class: ActiveRecordSpannerAdapter::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_spanner_adapter/table.rb,
lib/activerecord_spanner_adapter/table/column.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent_table: nil, on_delete: nil, schema_name: nil, catalog: nil) ⇒ Table

parent_table == interleave_in



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/activerecord_spanner_adapter/table.rb', line 37

def initialize \
    name,
    parent_table: nil,
    on_delete: nil,
    schema_name: nil,
    catalog: nil
  @name = name.to_s
  @parent_table = parent_table.to_s if parent_table
  @on_delete = on_delete
  @schema_name = schema_name
  @catalog = catalog
  @columns = []
  @indexes = []
  @foreign_keys = []
end

Instance Attribute Details

#catalogObject

Returns the value of attribute catalog.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def catalog
  @catalog
end

#columnsObject

Returns the value of attribute columns.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def columns
  @columns
end

#foreign_keysObject

Returns the value of attribute foreign_keys.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def foreign_keys
  @foreign_keys
end

#indexesObject

Returns the value of attribute indexes.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def indexes
  @indexes
end

#nameObject

Returns the value of attribute name.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def name
  @name
end

#on_deleteObject

Returns the value of attribute on_delete.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def on_delete
  @on_delete
end

#parent_tableObject

Returns the value of attribute parent_table.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def parent_table
  @parent_table
end

#schema_nameObject

Returns the value of attribute schema_name.



33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 33

def schema_name
  @schema_name
end

Instance Method Details

#cascade?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/activerecord_spanner_adapter/table.rb', line 57

def cascade?
  @on_delete == "CASCADE"
end

#primary_keysObject



53
54
55
# File 'lib/activerecord_spanner_adapter/table.rb', line 53

def primary_keys
  columns.select(&:primary_key).map(&:name)
end