Method: Traject::Indexer::EachRecordStep#validate!
- Defined in:
- lib/traject/indexer/step.rb
#validate! ⇒ Object
raises if bad data
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/traject/indexer/step.rb', line 45 def validate! unless self.lambda or self.block raise ArgumentError.new("Missing Argument: each_record must take a block/lambda as an argument (#{self.inspect})") end [self.lambda, self.block].each do |proc| # allow negative arity, meaning variable/optional, trust em on that. # but for positive arrity, we need 1 or 2 args if proc unless proc.is_a?(Proc) raise NamingError.new("argument to each_record must be a block/lambda, not a #{proc.class} #{self.inspect}") end if (proc.arity == 0 || proc.arity > 2) raise ArityError.new("block/proc given to each_record needs 1 or 2 arguments: #{self.inspect}") end end end end |