aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index c6c63291c9..52a8bea567 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -219,6 +219,14 @@ module ActiveRecord
end
end
+ def size
+ loaded? ? @records.length : count
+ end
+
+ def empty?
+ loaded? ? @records.empty? : count.zero?
+ end
+
def destroy_all
to_a.each {|object| object.destroy}
reset