Class: RuboCop::Rails::SchemaLoader::Schema
- Inherits:
-
Object
- Object
- RuboCop::Rails::SchemaLoader::Schema
- Defined in:
- lib/rubocop/rails/schema_loader/schema.rb
Overview
Represent db/schema.rb
Instance Attribute Summary collapse
-
#add_indices ⇒ Object
readonly
Returns the value of attribute add_indices.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
- #add_indices_by(table_name:) ⇒ Object
-
#initialize(ast) ⇒ Schema
constructor
A new instance of Schema.
- #table_by(name:) ⇒ Object
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_indices ⇒ Object (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 |
#tables ⇒ Object (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 |