Skip to content

Commit

Permalink
unfactoring module inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 6, 2010
1 parent 12ba765 commit c86f949
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
49 changes: 23 additions & 26 deletions lib/arel/algebra/attributes/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,37 @@ def to_attribute(relation)
bind(relation)
end

module Congruence
def history
@history ||= [self] + (ancestor ? ancestor.history : [])
end
def history
@history ||= [self] + (ancestor ? ancestor.history : [])
end

def join?
relation.join?
end
def join?
relation.join?
end

def root
history.last
end
def root
history.last
end

def original_relation
@original_relation ||= original_attribute.relation
end
def original_relation
@original_relation ||= original_attribute.relation
end

def original_attribute
@original_attribute ||= history.detect { |a| !a.join? }
end
def original_attribute
@original_attribute ||= history.detect { |a| !a.join? }
end

def find_correlate_in(relation)
relation[self] || self
end
def find_correlate_in(relation)
relation[self] || self
end

def descends_from?(other)
history.include?(other)
end
def descends_from?(other)
history.include?(other)
end

def /(other)
other ? (history & other.history).size : 0
end
def /(other)
other ? (history & other.history).size : 0
end
include Congruence

PREDICATES = [
:eq, :eq_any, :eq_all, :not_eq, :not_eq_any, :not_eq_all, :lt, :lt_any,
Expand Down
2 changes: 1 addition & 1 deletion spec/algebra/unit/primitives/attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module Arel
end
end

describe Attribute::Congruence do
describe 'Attribute::Congruence' do
describe '/' do
before do
@aliased_relation = @relation.alias
Expand Down

0 comments on commit c86f949

Please sign in to comment.