Class: Arel::Table

### Home Classes Methods

### In Files

- lib/arel/table.rb

### Parent

Object

### Methods

- ::new
- #[]
- #alias
- #columns
- #from
- #group
- #having
- #insert_manager
- #join
- #joins
- #order
- #primary_key
- #project
- #select_manager
- #skip
- #take
- #where

### Included Modules

- Arel::Crud
- Arel::FactoryMethods

### Files

- History.txt
- MIT-LICENSE.txt
- Manifest.txt

### Class/Module Index

Quicksearch

- Arel
- Arel::AliasPredication
- Arel::Attributes
- Arel::Attributes::Attribute
- Arel::Attributes::Boolean
- Arel::Attributes::Decimal
- Arel::Attributes::Float
- Arel::Attributes::Integer
- Arel::Attributes::String
- Arel::Attributes::Time
- Arel::Attributes::Undefined
- Arel::Crud
- Arel::DeleteManager
- Arel::Expression
- Arel::Expressions
- Arel::FactoryMethods
- Arel::InsertManager
- Arel::Math
- Arel::Nodes
- Arel::Nodes::Addition
- Arel::Nodes::And
- Arel::Nodes::Ascending
- Arel::Nodes::Binary
- Arel::Nodes::BindParam
- Arel::Nodes::Count
- Arel::Nodes::DeleteStatement
- Arel::Nodes::Descending
- Arel::Nodes::Distinct
- Arel::Nodes::Division
- Arel::Nodes::Equality
- Arel::Nodes::False
- Arel::Nodes::Function
- Arel::Nodes::In
- Arel::Nodes::InfixOperation
- Arel::Nodes::InnerJoin
- Arel::Nodes::InsertStatement
- Arel::Nodes::JoinSource
- Arel::Nodes::Multiplication
- Arel::Nodes::NamedFunction
- Arel::Nodes::Node
- Arel::Nodes::Ordering
- Arel::Nodes::OuterJoin
- Arel::Nodes::SelectCore
- Arel::Nodes::SelectStatement
- Arel::Nodes::SqlLiteral
- Arel::Nodes::StringJoin
- Arel::Nodes::Subtraction
- Arel::Nodes::TableAlias
- Arel::Nodes::True
- Arel::Nodes::Unary
- Arel::Nodes::UnqualifiedColumn
- Arel::Nodes::UpdateStatement
- Arel::Nodes::Values
- Arel::Nodes::With
- Arel::Nodes::WithRecursive
- Arel::OrderPredications
- Arel::Predications
- Arel::Relation
- Arel::SelectManager
- Arel::Sql
- Arel::Sql::Engine
- Arel::SqlLiteral
- Arel::Table
- Arel::TreeManager
- Arel::UpdateManager
- Arel::Visitors
- Arel::Visitors::BindVisitor
- Arel::Visitors::DepthFirst
- Arel::Visitors::Dot
- Arel::Visitors::IBM_DB
- Arel::Visitors::Informix
- Arel::Visitors::JoinSql
- Arel::Visitors::MSSQL
- Arel::Visitors::MySQL
- Arel::Visitors::Oracle
- Arel::Visitors::OrderClauses
- Arel::Visitors::PostgreSQL
- Arel::Visitors::SQLite
- Arel::Visitors::ToSql
- Arel::Visitors::Visitor
- Arel::Visitors::WhereSql

No matching classes.

# Arel::Table

### Attributes

engine[RW]
aliases[RW]
engine[RW]
name[RW]
table_alias[RW]
table_name[RW]

### Public Class Methods

new(name, engine = Table.engine) click to toggle source

    # File lib/arel/table.rb, line 14
    def initialize name, engine = Table.engine
      @name    = name.to_s
      @engine  = engine
      @columns = nil
      @aliases = []
      @table_alias = nil
      @primary_key = nil

      if Hash === engine
        @engine  = engine[:engine] || Table.engine

        # Sometime AR sends an :as parameter to table, to let the table know
        # that it is an Alias.  We may want to override new, and return a
        # TableAlias node?
        @table_alias = engine[:as] unless engine[:as].to_s == @name
      end
    end

### Public Instance Methods

[](name) click to toggle source

    # File lib/arel/table.rb, line 114
    def [] name
      ::Arel::Attribute.new self, name
    end

alias(name = "#{self.name}_2") click to toggle source

    # File lib/arel/table.rb, line 45
    def alias name = "#{self.name}_2"
      Nodes::TableAlias.new(self, name).tap do |node|
        @aliases << node
      end
    end

columns() click to toggle source

    # File lib/arel/table.rb, line 103
    def columns
      if $VERBOSE
        warn (#{caller.first}) Arel::Table#columns is deprecated and will be removed inArel 4.0.0 with no replacement.  PEW PEW PEW!!!
      end
      @columns ||=
        attributes_for @engine.connection.columns(@name, "#{@name} Columns")
    end

from(table) click to toggle source

    # File lib/arel/table.rb, line 51
    def from table
      SelectManager.new(@engine, table)
    end

group(*columns) click to toggle source

    # File lib/arel/table.rb, line 75
    def group *columns
      from(self).group(*columns)
    end

having(expr) click to toggle source

    # File lib/arel/table.rb, line 99
    def having expr
      from(self).having expr
    end

insert_manager() click to toggle source

    # File lib/arel/table.rb, line 122
    def insert_manager
      InsertManager.new(@engine)
    end

join(relation, klass = Nodes::InnerJoin) click to toggle source

    # File lib/arel/table.rb, line 63
    def join relation, klass = Nodes::InnerJoin
      return from(self) unless relation

      case relation
      when String, Nodes::SqlLiteral
        raise if relation.blank?
        klass = Nodes::StringJoin
      end

      from(self).join(relation, klass)
    end

joins(manager) click to toggle source

    # File lib/arel/table.rb, line 55
    def joins manager
      if $VERBOSE
        warn "joins is deprecated and will be removed in 4.0.0"
        warn "please remove your call to joins from #{caller.first}"
      end
      nil
    end

order(*expr) click to toggle source

    # File lib/arel/table.rb, line 79
    def order *expr
      from(self).order(*expr)
    end

primary_key() click to toggle source

    # File lib/arel/table.rb, line 32
    def primary_key
      if $VERBOSE
        warn primary_key (#{caller.first}) is deprecated and will be removed in ARel 4.0.0
      end
      @primary_key ||= begin
        primary_key_name = @engine.connection.primary_key(name)
        # some tables might be without primary key
        primary_key_name && self[primary_key_name]
      end
    end

project(*things) click to toggle source

    # File lib/arel/table.rb, line 87
    def project *things
      from(self).project(*things)
    end

select_manager() click to toggle source

    # File lib/arel/table.rb, line 118
    def select_manager
      SelectManager.new(@engine)
    end

skip(amount) click to toggle source

    # File lib/arel/table.rb, line 95
    def skip amount
      from(self).skip amount
    end

take(amount) click to toggle source

    # File lib/arel/table.rb, line 91
    def take amount
      from(self).take amount
    end

where(condition) click to toggle source

    # File lib/arel/table.rb, line 83
    def where condition
      from(self).where condition
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.