Skip to content

Commit

Permalink
removing module for faster method lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jul 31, 2010
1 parent 020b037 commit 34303cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions lib/arel/algebra/expression.rb
Expand Up @@ -20,20 +20,17 @@ def to_sql(formatter = Sql::SelectClause.new(relation))
formatter.expression self
end

module Transformations
def as(aliaz)
self.class.new(attribute, aliaz, self)
end

def bind(new_relation)
new_relation == relation ? self : self.class.new(attribute.bind(new_relation), @alias, self)
end

def to_attribute(relation)
Attribute.new(relation, @alias, :ancestor => self)
end
def as(aliaz)
self.class.new(attribute, aliaz, self)
end

def bind(new_relation)
new_relation == relation ? self : self.class.new(attribute.bind(new_relation), @alias, self)
end

def to_attribute(relation)
Attribute.new(relation, @alias, :ancestor => self)
end
include Transformations
end

class Count < Expression
Expand Down
2 changes: 1 addition & 1 deletion spec/algebra/unit/primitives/expression_spec.rb
Expand Up @@ -7,7 +7,7 @@ module Arel
@attribute = @relation[:id]
end

describe Expression::Transformations do
describe 'Expression::Transformations' do
before do
@expression = Count.new(@attribute)
end
Expand Down

0 comments on commit 34303cc

Please sign in to comment.