aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-13 22:46:12 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-13 22:46:12 -0700
commita8cf09a5b6bd4019e0f68e70d62d6e6be6b3784b (patch)
tree5d7cb44278250098b95db9f7b3bdb9889a84e2b7 /lib
parentc823c2c2cc3e5d0a709d67e585e73fde0f11512f (diff)
downloadrails-a8cf09a5b6bd4019e0f68e70d62d6e6be6b3784b.tar.gz
rails-a8cf09a5b6bd4019e0f68e70d62d6e6be6b3784b.tar.bz2
rails-a8cf09a5b6bd4019e0f68e70d62d6e6be6b3784b.zip
added abstract declaration
Diffstat (limited to 'lib')
-rw-r--r--lib/active_relation.rb2
-rw-r--r--lib/active_relation/extensions.rb1
-rw-r--r--lib/active_relation/extensions/class.rb17
-rw-r--r--lib/active_relation/extensions/object.rb10
-rw-r--r--lib/active_relation/sql.rb2
5 files changed, 22 insertions, 10 deletions
diff --git a/lib/active_relation.rb b/lib/active_relation.rb
index f04825ad4c..5b5c91706f 100644
--- a/lib/active_relation.rb
+++ b/lib/active_relation.rb
@@ -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'
diff --git a/lib/active_relation/extensions.rb b/lib/active_relation/extensions.rb
index 8a024947ed..7268a5549b 100644
--- a/lib/active_relation/extensions.rb
+++ b/lib/active_relation/extensions.rb
@@ -1,3 +1,4 @@
require 'active_relation/extensions/object'
+require 'active_relation/extensions/class'
require 'active_relation/extensions/array'
require 'active_relation/extensions/hash'
diff --git a/lib/active_relation/extensions/class.rb b/lib/active_relation/extensions/class.rb
new file mode 100644
index 0000000000..0e5b728c26
--- /dev/null
+++ b/lib/active_relation/extensions/class.rb
@@ -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 \ No newline at end of file
diff --git a/lib/active_relation/extensions/object.rb b/lib/active_relation/extensions/object.rb
index ab874150ed..90eb73f0b0 100644
--- a/lib/active_relation/extensions/object.rb
+++ b/lib/active_relation/extensions/object.rb
@@ -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
diff --git a/lib/active_relation/sql.rb b/lib/active_relation/sql.rb
index b38e6dc392..e5a4eed08b 100644
--- a/lib/active_relation/sql.rb
+++ b/lib/active_relation/sql.rb
@@ -8,6 +8,8 @@ module ActiveRelation
attr_reader :engine
include Quoting
+ abstract :attribute, :select, :value
+
def initialize(engine)
@engine = engine
end