1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

added abstract declaration

This commit is contained in:
Nick Kallen 2008-03-13 22:46:12 -07:00
parent c823c2c2cc
commit a8cf09a5b6
6 changed files with 22 additions and 18 deletions

View file

@ -4,8 +4,8 @@ require 'rubygems'
require 'activesupport'
require 'activerecord'
require 'active_relation/sql'
require 'active_relation/extensions'
require 'active_relation/sql'
require 'active_relation/predicates'
require 'active_relation/relations'
require 'active_relation/engines'

View file

@ -1,3 +1,4 @@
require 'active_relation/extensions/object'
require 'active_relation/extensions/class'
require 'active_relation/extensions/array'
require 'active_relation/extensions/hash'

View file

@ -0,0 +1,17 @@
class Class
def abstract(*methods)
methods.each do |method|
define_method method do
raise NotImplementedError
end
end
end
def hash_on(delegatee)
define_method :eql? do |other|
self == other
end
delegate :hash, :to => delegatee
end
end

View file

@ -1,12 +1,4 @@
class Object
def self.hash_on(delegatee)
def eql?(other)
self == other
end
delegate :hash, :to => delegatee
end
class Object
def bind(relation)
ActiveRelation::Value.new(self, relation)
end

View file

@ -8,6 +8,8 @@ module ActiveRelation
attr_reader :engine
include Quoting
abstract :attribute, :select, :value
def initialize(engine)
@engine = engine
end

View file

@ -21,13 +21,5 @@ module ActiveRelation
@compound_relation.attributes.should == @relation.attributes.collect { |a| a.bind(@compound_relation) }
end
end
describe 'hashing' do
it 'implements hash equality' do
hash = {}
hash[@compound_relation] = 1
hash[ConcreteCompound.new(@relation)].should == 1
end
end
end
end