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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/activerecord_spanner_adapter/table.rb', line 21

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.



15
16
17
# File 'lib/activerecord_spanner_adapter/table.rb', line 15

def catalog
  @catalog
end

#columnsObject

Returns the value of attribute columns.



17
18
19
# File 'lib/activerecord_spanner_adapter/table.rb', line 17

def columns
  @columns
end

#foreign_keysObject

Returns the value of attribute foreign_keys.



18
19
20
# File 'lib/activerecord_spanner_adapter/table.rb', line 18

def foreign_keys
  @foreign_keys
end

#indexesObject

Returns the value of attribute indexes.



16
17
18
# File 'lib/activerecord_spanner_adapter/table.rb', line 16

def indexes
  @indexes
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/activerecord_spanner_adapter/table.rb', line 11

def name
  @name
end

#on_deleteObject

Returns the value of attribute on_delete.



12
13
14
# File 'lib/activerecord_spanner_adapter/table.rb', line 12

def on_delete
  @on_delete
end

#parent_tableObject

Returns the value of attribute parent_table.



13
14
15
# File 'lib/activerecord_spanner_adapter/table.rb', line 13

def parent_table
  @parent_table
end

#schema_nameObject

Returns the value of attribute schema_name.



14
15
16
# File 'lib/activerecord_spanner_adapter/table.rb', line 14

def schema_name
  @schema_name
end

Instance Method Details

#cascade?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/activerecord_spanner_adapter/table.rb', line 41

def cascade?
  @on_delete == "CASCADE"
end

#primary_keysObject



37
38
39
# File 'lib/activerecord_spanner_adapter/table.rb', line 37

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