Module: ActiveRecord::NullRelation
- Defined in:
- lib/active_record/null_relation.rb
Overview
:nodoc:
Instance Method Summary collapse
- #any? ⇒ Boolean
- #average ⇒ Object
- #calculate(operation, _column_name) ⇒ Object
- #count ⇒ Object
- #delete(_id_or_array) ⇒ Object
- #delete_all(_conditions = nil) ⇒ Object
- #empty? ⇒ Boolean
- #exec_queries ⇒ Object
- #exists?(_conditions = :none) ⇒ Boolean
- #many? ⇒ Boolean
- #maximum ⇒ Object
- #minimum ⇒ Object
- #none? ⇒ Boolean
- #one? ⇒ Boolean
- #or(other) ⇒ Object
- #pluck(*column_names) ⇒ Object
- #size ⇒ Object
- #sum ⇒ Object
- #to_sql ⇒ Object
- #update_all(_updates) ⇒ Object
Instance Method Details
#any? ⇒ Boolean
35 36 37 |
# File 'lib/active_record/null_relation.rb', line 35 def any? false end |
#average ⇒ Object
59 60 61 |
# File 'lib/active_record/null_relation.rb', line 59 def average(*) calculate :average, nil end |
#calculate(operation, _column_name) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/active_record/null_relation.rb', line 71 def calculate(operation, _column_name) if [:count, :sum, :size].include? operation group_values.any? ? Hash.new : 0 elsif [:average, :minimum, :maximum].include?(operation) && group_values.any? Hash.new else nil end end |
#count ⇒ Object
51 52 53 |
# File 'lib/active_record/null_relation.rb', line 51 def count(*) calculate :count, nil end |
#delete(_id_or_array) ⇒ Object
19 20 21 |
# File 'lib/active_record/null_relation.rb', line 19 def delete(_id_or_array) 0 end |
#delete_all(_conditions = nil) ⇒ Object
11 12 13 |
# File 'lib/active_record/null_relation.rb', line 11 def delete_all(_conditions = nil) 0 end |
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/active_record/null_relation.rb', line 27 def empty? true end |
#exec_queries ⇒ Object
3 4 5 |
# File 'lib/active_record/null_relation.rb', line 3 def exec_queries @records = [].freeze end |
#exists?(_conditions = :none) ⇒ Boolean
81 82 83 |
# File 'lib/active_record/null_relation.rb', line 81 def exists?(_conditions = :none) false end |
#many? ⇒ Boolean
43 44 45 |
# File 'lib/active_record/null_relation.rb', line 43 def many? false end |
#maximum ⇒ Object
67 68 69 |
# File 'lib/active_record/null_relation.rb', line 67 def maximum(*) calculate :maximum, nil end |
#minimum ⇒ Object
63 64 65 |
# File 'lib/active_record/null_relation.rb', line 63 def minimum(*) calculate :minimum, nil end |
#none? ⇒ Boolean
31 32 33 |
# File 'lib/active_record/null_relation.rb', line 31 def none? true end |
#one? ⇒ Boolean
39 40 41 |
# File 'lib/active_record/null_relation.rb', line 39 def one? false end |
#or(other) ⇒ Object
85 86 87 |
# File 'lib/active_record/null_relation.rb', line 85 def or(other) other.spawn end |
#pluck(*column_names) ⇒ Object
7 8 9 |
# File 'lib/active_record/null_relation.rb', line 7 def pluck(*column_names) [] end |
#size ⇒ Object
23 24 25 |
# File 'lib/active_record/null_relation.rb', line 23 def size calculate :size, nil end |
#sum ⇒ Object
55 56 57 |
# File 'lib/active_record/null_relation.rb', line 55 def sum(*) calculate :sum, nil end |
#to_sql ⇒ Object
47 48 49 |
# File 'lib/active_record/null_relation.rb', line 47 def to_sql "" end |
#update_all(_updates) ⇒ Object
15 16 17 |
# File 'lib/active_record/null_relation.rb', line 15 def update_all(_updates) 0 end |