Sha256: e3319a2432929bd0bbb6487de3971fc248acd1126c811a74877458e183c80d59
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true class Serega module SeregaPlugins module Batch # # Validator for option :loader in attribute :batch option # class CheckBatchOptLoader class << self # # Checks option :loader of attribute :batch option # # @param loader [nil, #call] Attribute :batch option :loader # # @raise [SeregaError] validation error # # @return [void] # def call(loader) return if loader.is_a?(Symbol) raise SeregaError, must_be_callable unless loader.respond_to?(:call) SeregaValidations::Utils::CheckExtraKeywordArg.call(loader, ":batch option :loader") params_count = SeregaUtils::ParamsCount.call(loader, max_count: 3) raise SeregaError, params_count_error if params_count > 3 end private def params_count_error "Invalid :batch option :loader. It can accept maximum 3 parameters (keys, context, plan)" end def must_be_callable "Invalid :batch option :loader. It must be a Symbol, a Proc or respond to :call" end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
serega-0.17.0 | lib/serega/plugins/batch/lib/validations/check_batch_opt_loader.rb |