diff options
author | Juanjo Bazán <jjbazan@gmail.com> | 2012-04-11 15:24:23 +0200 |
---|---|---|
committer | Juanjo Bazán <jjbazan@gmail.com> | 2012-04-11 15:24:23 +0200 |
commit | 1a20683f0919680de4875c8097e7114a529aeb88 (patch) | |
tree | 93a740c9fec7cbc8baf06249ef5e080663f66044 /activerecord/lib/active_record | |
parent | b79b784f7290fdfab917bb8e44a9477a709318c5 (diff) | |
download | rails-1a20683f0919680de4875c8097e7114a529aeb88.tar.gz rails-1a20683f0919680de4875c8097e7114a529aeb88.tar.bz2 rails-1a20683f0919680de4875c8097e7114a529aeb88.zip |
Override AR::Relation methods in NullRelation.
So a NullRelation (Relation#none) is chainable with database methods.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/null_relation.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 60c37ac2b7..c2d3eeb8ce 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -6,5 +6,58 @@ module ActiveRecord def exec_queries @records = [] end + + def pluck(column_name) + [] + end + + def delete_all(conditions = nil) + 0 + end + + def update_all(updates, conditions = nil, options = {}) + 0 + end + + def delete(id_or_array) + 0 + end + + def size + 0 + end + + def empty? + true + end + + def any? + false + end + + def many? + false + end + + def to_sql + @to_sql ||= "" + end + + def where_values_hash + {} + end + + def count + 0 + end + + def calculate(operation, column_name, options = {}) + nil + end + + def exists?(id = false) + false + end + end end
\ No newline at end of file |