Module: ActiveRecord::NullRelation

Defined in:
lib/active_record/null_relation.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/active_record/null_relation.rb', line 33

def any?
  false
end

#calculate(operation, _column_name, _options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/active_record/null_relation.rb', line 53

def calculate(operation, _column_name, _options = {})
  # TODO: Remove _options argument as soon we remove support to
  # activerecord-deprecated_finders.
  if operation == :count
    group_values.any? ? Hash.new : 0
  else
    nil
  end
end

#countObject



45
46
47
# File 'lib/active_record/null_relation.rb', line 45

def count(*)
  calculate :count, nil
end

#delete(_id_or_array) ⇒ Object



21
22
23
# File 'lib/active_record/null_relation.rb', line 21

def delete(_id_or_array)
  0
end

#delete_all(_conditions = nil) ⇒ Object



13
14
15
# File 'lib/active_record/null_relation.rb', line 13

def delete_all(_conditions = nil)
  0
end

#empty?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/active_record/null_relation.rb', line 29

def empty?
  true
end

#exec_queriesObject



5
6
7
# File 'lib/active_record/null_relation.rb', line 5

def exec_queries
  @records = []
end

#exists?(_id = false) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/active_record/null_relation.rb', line 63

def exists?(_id = false)
  false
end

#many?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/active_record/null_relation.rb', line 37

def many?
  false
end

#pluck(*column_names) ⇒ Object



9
10
11
# File 'lib/active_record/null_relation.rb', line 9

def pluck(*column_names)
  []
end

#sizeObject



25
26
27
# File 'lib/active_record/null_relation.rb', line 25

def size
  0
end

#sumObject



49
50
51
# File 'lib/active_record/null_relation.rb', line 49

def sum(*)
  0
end

#to_sqlObject



41
42
43
# File 'lib/active_record/null_relation.rb', line 41

def to_sql
  @to_sql ||= ""
end

#update_all(_updates, _conditions = nil, _options = {}) ⇒ Object



17
18
19
# File 'lib/active_record/null_relation.rb', line 17

def update_all(_updates, _conditions = nil, _options = {})
  0
end