diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-11 22:42:47 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-11 22:42:47 -0700 |
commit | a29ceffc9476c99ff02f0617d2e38627c526bac2 (patch) | |
tree | fc9aa702ad9a2f506a4a51b71791798fb8a6ca4b /lib | |
parent | 98527c8f7dd64f086895c1576fb33e8b91071142 (diff) | |
download | rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.tar.gz rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.tar.bz2 rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.zip |
implemented hashing macro; implemented custom matcher testing this macro
Diffstat (limited to 'lib')
-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 |