Class: RuboCop::Rails::SchemaLoader::Table

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

Overview

Represent a table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Table

Returns a new instance of Table.



74
75
76
77
78
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 74

def initialize(node)
  @name = node.send_node.first_argument.value
  @columns = build_columns(node)
  @indices = build_indices(node)
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



72
73
74
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 72

def columns
  @columns
end

#indicesObject (readonly)

Returns the value of attribute indices.



72
73
74
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 72

def indices
  @indices
end

#nameObject (readonly)

Returns the value of attribute name.



72
73
74
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 72

def name
  @name
end

Instance Method Details

#with_column?(name:) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/rubocop/rails/schema_loader/schema.rb', line 80

def with_column?(name:)
  @columns.any? { |c| c.name == name }
end