Class: RuboCop::Rails::SchemaLoader::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/rails/schema_loader/schema.rb

Overview

Represent db/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast) ⇒ Schema

Returns a new instance of Schema.



10
11
12
13
14
15
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 10

def initialize(ast)
  @tables = []
  @add_indices = []

  build!(ast)
end

Instance Attribute Details

#add_indicesObject (readonly)

Returns the value of attribute add_indices.



8
9
10
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 8

def add_indices
  @add_indices
end

#tablesObject (readonly)

Returns the value of attribute tables.



8
9
10
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 8

def tables
  @tables
end

Instance Method Details

#add_indices_by(table_name:) ⇒ Object



23
24
25
26
27
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 23

def add_indices_by(table_name:)
  add_indices.select do |add_index|
    add_index.table_name == table_name
  end
end

#table_by(name:) ⇒ Object



17
18
19
20
21
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 17

def table_by(name:)
  tables.find do |table|
    table.name == name
  end
end