Class: Esse::Plugins::AsyncIndexing::RepositoryClassMethods::AsyncIndexingJobValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/esse/plugins/async_indexing.rb

Constant Summary collapse

OPERATIONS =
%i[import index update delete].freeze

Class Method Summary collapse

Class Method Details

.call(operations, block) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/esse/plugins/async_indexing.rb', line 92

def self.call(operations, block)
  unless block.is_a?(Proc)
    raise ArgumentError, "The block of async_indexing_job must be a callable object"
  end

  operations.each do |operation|
    next if OPERATIONS.include?(operation)
    raise ArgumentError, format("Unrecognized operation: %<operation>p. Valid operations are: %<valid>p", operation: operation, valid: OPERATIONS)
  end
end