diff options
Diffstat (limited to 'lib/active_relation')
-rw-r--r-- | lib/active_relation/.DS_Store | bin | 6148 -> 6148 bytes | |||
-rw-r--r-- | lib/active_relation/extensions/object.rb | 10 | ||||
-rw-r--r-- | lib/active_relation/primitives/attribute.rb | 5 | ||||
-rw-r--r-- | lib/active_relation/relations/relation.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/relations/table.rb | 2 |
5 files changed, 11 insertions, 10 deletions
diff --git a/lib/active_relation/.DS_Store b/lib/active_relation/.DS_Store Binary files differindex 2a449ff62e..9918127870 100644 --- a/lib/active_relation/.DS_Store +++ b/lib/active_relation/.DS_Store diff --git a/lib/active_relation/extensions/object.rb b/lib/active_relation/extensions/object.rb index d13cf9aabb..c1269ee37b 100644 --- a/lib/active_relation/extensions/object.rb +++ b/lib/active_relation/extensions/object.rb @@ -1,4 +1,12 @@ -class Object +class Object + def self.hash_on(delegatee) + def eql?(other) + self == other + end + + delegate :hash, :to => delegatee + end + def bind(relation) ActiveRelation::Scalar.new(self, relation) end diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb index baaae1973c..20677f824b 100644 --- a/lib/active_relation/primitives/attribute.rb +++ b/lib/active_relation/primitives/attribute.rb @@ -48,10 +48,7 @@ module ActiveRelation module Congruence def self.included(klass) - klass.class_eval do - alias_method :eql?, :== - delegate :hash, :to => :name - end + klass.hash_on :name end def history diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index 1c97cc7035..f9823bf92d 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -102,10 +102,6 @@ module ActiveRelation false end - def eql?(other) - self == other - end - def to_sql(strategy = Sql::Relation.new(engine)) strategy.select [ "SELECT #{attributes.collect{ |a| a.to_sql(Sql::Projection.new(engine)) }.join(', ')}", diff --git a/lib/active_relation/relations/table.rb b/lib/active_relation/relations/table.rb index 84eb1213ee..4682298608 100644 --- a/lib/active_relation/relations/table.rb +++ b/lib/active_relation/relations/table.rb @@ -3,7 +3,7 @@ module ActiveRelation cattr_accessor :engine attr_reader :name, :engine - delegate :hash, :to => :name + hash_on :name def initialize(name, engine = Table.engine) @name, @engine = name.to_s, engine |