lib/bulk_loader/loader.rb in bulk_loader-1.2.0 vs lib/bulk_loader/loader.rb in bulk_loader-1.3.0

- old
+ new

@@ -11,10 +11,12 @@ @is_default_proc = @default.is_a?(Proc) @block = block end def load(lazy_objs, *args) + return if lazy_objs.empty? + mapping_of = get_mapping(lazy_objs) result_of = call_block(mapping_of, *args) lazy_objs.each(&:clear) @@ -30,9 +32,10 @@ if args.size < @block.arity - 1 message = "block should take #{@block.arity} parameters, but given #{arity.size + 1}" raise ArgumentError, message end result_of = @block.call(mapping_of.keys, *args) + raise 'block shuold return Hash' unless result_of.is_a?(Hash) result_of end