aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-06 14:05:56 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-06 14:05:56 -0700
commitc86f94986d60d607f374ef01f9b6428fc64ddc81 (patch)
tree4ca5334586657fad4b8fde6efed825d4a138a096
parent12ba765448582cb86e5f57d6befc42c59eb295d9 (diff)
downloadrails-c86f94986d60d607f374ef01f9b6428fc64ddc81.tar.gz
rails-c86f94986d60d607f374ef01f9b6428fc64ddc81.tar.bz2
rails-c86f94986d60d607f374ef01f9b6428fc64ddc81.zip
unfactoring module inclusion
-rw-r--r--lib/arel/algebra/attributes/attribute.rb49
-rw-r--r--spec/algebra/unit/primitives/attribute_spec.rb2
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