Module: ActiveRecord::NullRelation

Defined in:
lib/active_record/null_relation.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/active_record/null_relation.rb', line 27

def any?
  false
end

#calculate(operation, _column_name) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/active_record/null_relation.rb', line 43

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



15
16
17
# File 'lib/active_record/null_relation.rb', line 15

def delete(_id_or_array)
  0
end

#delete_allObject



7
8
9
# File 'lib/active_record/null_relation.rb', line 7

def delete_all
  0
end

#empty?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/active_record/null_relation.rb', line 19

def empty?
  true
end

#exists?(_conditions = :none) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/active_record/null_relation.rb', line 52

def exists?(_conditions = :none)
  false
end

#many?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_record/null_relation.rb', line 35

def many?
  false
end

#none?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/active_record/null_relation.rb', line 23

def none?
  true
end

#one?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/active_record/null_relation.rb', line 31

def one?
  false
end

#or(other) ⇒ Object



56
57
58
# File 'lib/active_record/null_relation.rb', line 56

def or(other)
  other.spawn
end

#pluck(*column_names) ⇒ Object



3
4
5
# File 'lib/active_record/null_relation.rb', line 3

def pluck(*column_names)
  []
end

#to_sqlObject



39
40
41
# File 'lib/active_record/null_relation.rb', line 39

def to_sql
  ""
end

#update_all(_updates) ⇒ Object



11
12
13
# File 'lib/active_record/null_relation.rb', line 11

def update_all(_updates)
  0
end