From c86f94986d60d607f374ef01f9b6428fc64ddc81 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 6 Aug 2010 14:05:56 -0700 Subject: unfactoring module inclusion --- lib/arel/algebra/attributes/attribute.rb | 49 ++++++++++++-------------- spec/algebra/unit/primitives/attribute_spec.rb | 2 +- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb index 2a4b274a96..5b391f86b0 100644 --- a/lib/arel/algebra/attributes/attribute.rb +++ b/lib/arel/algebra/attributes/attribute.rb @@ -58,40 +58,37 @@ module Arel 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, diff --git a/spec/algebra/unit/primitives/attribute_spec.rb b/spec/algebra/unit/primitives/attribute_spec.rb index 08d32614a1..4026c0de14 100644 --- a/spec/algebra/unit/primitives/attribute_spec.rb +++ b/spec/algebra/unit/primitives/attribute_spec.rb @@ -52,7 +52,7 @@ module Arel end end - describe Attribute::Congruence do + describe 'Attribute::Congruence' do describe '/' do before do @aliased_relation = @relation.alias -- cgit v1.2.3