diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-18 08:27:37 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-18 08:27:37 -0300 |
commit | ac03bc91dbee36233e061eb624f7781a49ab6fcf (patch) | |
tree | a76cd748816e4e00d54855e6d8a9d167a1ea7cfd | |
parent | fa8f5c2667fa82feab66aa102993ab4f123d42bc (diff) | |
download | rails-ac03bc91dbee36233e061eb624f7781a49ab6fcf.tar.gz rails-ac03bc91dbee36233e061eb624f7781a49ab6fcf.tar.bz2 rails-ac03bc91dbee36233e061eb624f7781a49ab6fcf.zip |
Use explicit method definition instead of metaprogramming.
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 0d43c53d10..9c7ba881fc 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -1,7 +1,6 @@ module ActiveRecord class Relation - delegate :delete, :to_sql, :to => :relation - CLAUSES_METHODS = ["group", "order", "on"].freeze + delegate :to_sql, :to => :relation attr_reader :relation, :klass def initialize(klass, table = nil) @@ -22,20 +21,26 @@ module ActiveRecord to_a.first end - for clause in CLAUSES_METHODS - class_eval %{ - def #{clause}!(_#{clause}) - @relation = @relation.#{clause}(_#{clause}) if _#{clause} - self - end - } - end - def select!(selection) @relation = @relation.project(selection) if selection self end + def on!(on) + @relation = @relation.on(on) if on + self + end + + def order!(order) + @relation = @relation.order(order) if order + self + end + + def group!(group) + @relation = @relation.group(group) if group + self + end + def limit!(limit) @relation = @relation.take(limit) if limit self |