Module: ActiveRecord::NullRelation

Defined in:
activerecord/lib/active_record/null_relation.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


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

def any?
  false
end

#calculate(operation, _column_name) ⇒ Object



45
46
47
48
49
50
51
52
# File 'activerecord/lib/active_record/null_relation.rb', line 45

def calculate(operation, _column_name)
  case operation
  when :count, :sum
    group_values.any? ? Hash.new : 0
  when :average, :minimum, :maximum
    group_values.any? ? Hash.new : nil
  end
end

#delete(_id_or_array) ⇒ Object



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

def delete(_id_or_array)
  0
end

#delete_allObject



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

def delete_all
  0
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  true
end

#exists?(_conditions = :none) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'activerecord/lib/active_record/null_relation.rb', line 54

def exists?(_conditions = :none)
  false
end

#many?Boolean

Returns:

  • (Boolean)


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

def many?
  false
end

#none?Boolean

Returns:

  • (Boolean)


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

def none?
  true
end

#one?Boolean

Returns:

  • (Boolean)


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

def one?
  false
end

#or(other) ⇒ Object



58
59
60
# File 'activerecord/lib/active_record/null_relation.rb', line 58

def or(other)
  other.spawn
end

#pluck(*column_names) ⇒ Object



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

def pluck(*column_names)
  []
end

#to_sqlObject



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

def to_sql
  ""
end

#update_all(_updates) ⇒ Object



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

def update_all(_updates)
  0
end