class RuboCop::Rails::SchemaLoader::Table
Represent a table
def build_columns(node)
def build_columns(node) each_content(node).filter_map do |child| next unless child&.send_type? next if child.method?(:index) Column.new(child) end end
def build_indices(node)
def build_indices(node) each_content(node).filter_map do |child| next unless child&.send_type? next unless child.method?(:index) Index.new(child) end end
def each_content(node, &block)
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
def initialize(node)
def initialize(node) @name = node.send_node.first_argument.value @columns = build_columns(node) @indices = build_indices(node) end
def with_column?(name:)
def with_column?(name:) @columns.any? { |c| c.name == name } end