Module: OrderCop::OrderCopMixin

Defined in:
lib/order_cop.rb

Instance Method Summary collapse

Instance Method Details

#eachObject

patch all methods which iterate over the collection and return several records

we don't patch `first` and `last`, take or others because they return a single record)
we don't patch sort because it specifically doesn't need an order
we don't patch select as it's a query method


66
67
68
69
# File 'lib/order_cop.rb', line 66

def each(...)
  detect_missing_order(:each) if order_values.empty?
  super(...)
end

#find_eachObject



81
82
83
84
# File 'lib/order_cop.rb', line 81

def find_each(...)
  detect_missing_order(:find_each) if order_values.empty?
  super(...)
end

#find_in_batchesObject



86
87
88
89
# File 'lib/order_cop.rb', line 86

def find_in_batches(...)
  detect_missing_order(:find_in_batches) if order_values.empty?
  super(...)
end

#mapObject



76
77
78
79
# File 'lib/order_cop.rb', line 76

def map(...)
  detect_missing_order(:map) if order_values.empty?
  super(...)
end

#rejectObject



91
92
93
94
# File 'lib/order_cop.rb', line 91

def reject(...)
  detect_missing_order(:reject) if order_values.empty?
  super(...)
end

#reject!(&block) ⇒ Object



96
97
98
99
# File 'lib/order_cop.rb', line 96

def reject!(&block)
  detect_missing_order(:reject!) if order_values.empty?
  super(&block)
end

#to_aObject



71
72
73
74
# File 'lib/order_cop.rb', line 71

def to_a
  detect_missing_order(:to_a) if order_values.empty?
  super
end