Exception: WhereComposite::TooManyIds

Inherits:
ArgumentError
  • Object
show all
Defined in:
app/models/concerns/where_composite.rb

Constant Summary collapse

LIMIT =
100

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(no_of_ids) ⇒ TooManyIds

Returns a new instance of TooManyIds.



9
10
11
12
13
14
# File 'app/models/concerns/where_composite.rb', line 9

def initialize(no_of_ids)
  super(<<~MSG)
  At most #{LIMIT} identifier sets at a time please! Got #{no_of_ids}.
  Have you considered splitting your request into batches?
  MSG
end

Class Method Details

.guard(collection) ⇒ Object

Raises:

  • (self)


16
17
18
19
20
21
# File 'app/models/concerns/where_composite.rb', line 16

def self.guard(collection)
  n = collection.size
  return collection if n <= LIMIT

  raise self, n
end