Class: ActiveRecord::ConnectionAdapters::Spanner::IndexDefinition

Inherits:
IndexDefinition
  • Object
show all
Defined in:
lib/active_record/connection_adapters/spanner/schema_definitions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, name, columns, unique: false, null_filtered: false, interleave_in: nil, storing: nil, orders: nil) ⇒ IndexDefinition

Returns a new instance of IndexDefinition.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 101

def initialize \
    table_name,
    name,
    columns,
    unique: false,
    null_filtered: false,
    interleave_in: nil,
    storing: nil,
    orders: nil
  @table = table_name
  @name = name
  @unique = unique
  @null_filtered = null_filtered
  @interleave_in = interleave_in
  @storing = Array(storing)
  columns = columns.split(/\W/) if columns.is_a? String
  @columns = Array(columns).map(&:to_s)
  @orders = orders || {}

  unless @orders.is_a? Hash
    @orders = columns.each_with_object({}) { |c, r| r[c] = orders }
  end

  @orders = @orders.symbolize_keys
end

Instance Attribute Details

#interleave_inObject (readonly)

Returns the value of attribute interleave_in.



99
100
101
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 99

def interleave_in
  @interleave_in
end

#null_filteredObject (readonly)

Returns the value of attribute null_filtered.



99
100
101
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 99

def null_filtered
  @null_filtered
end

#ordersObject (readonly)

Returns the value of attribute orders.



99
100
101
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 99

def orders
  @orders
end

#storingObject (readonly)

Returns the value of attribute storing.



99
100
101
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 99

def storing
  @storing
end

Instance Method Details

#columns_with_orderObject



127
128
129
130
131
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 127

def columns_with_order
  columns.each_with_object({}) do |c, result|
    result[c] = orders[c.to_sym].to_s.upcase
  end
end