class RuboCop::Rails::SchemaLoader::Table
Represent a table
Attributes
columns[R]
indices[R]
name[R]
Public Class Methods
new(node)
click to toggle source
# File lib/rubocop/rails/schema_loader/schema.rb, line 70 def initialize(node) @name = node.send_node.first_argument.value @columns = build_columns(node) @indices = build_indices(node) end
Public Instance Methods
with_column?(name:)
click to toggle source
# File lib/rubocop/rails/schema_loader/schema.rb, line 76 def with_column?(name:) @columns.any? { |c| c.name == name } end
Private Instance Methods
build_columns(node)
click to toggle source
# File lib/rubocop/rails/schema_loader/schema.rb, line 82 def build_columns(node) each_content(node).map do |child| next unless child&.send_type? next if child.method?(:index) Column.new(child) end.compact end
build_indices(node)
click to toggle source
# File lib/rubocop/rails/schema_loader/schema.rb, line 91 def build_indices(node) each_content(node).map do |child| next unless child&.send_type? next unless child.method?(:index) Index.new(child) end.compact end
each_content(node) { |body| ... }
click to toggle source
# File lib/rubocop/rails/schema_loader/schema.rb, line 100 def each_content(node, &block) return enum_for(__method__, node) unless block case node.body&.type when :begin node.body.children.each(&block) else yield(node.body) end end