Sha256: bfc5f980a1681023a596467d88bd1fce4df2de55fbd6d1add0f4b22205f9526a

Contents?: true

Size: 768 Bytes

Versions: 5

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

class Serega
  module SeregaPlugins
    module Batch
      class SeregaBatchLoaders
        module InstanceMethods
          def get(point, object_serializer)
            batch_loaders[point] ||= self.class.serializer_class::SeregaBatchLoader.new(object_serializer, point)
          end

          def load_all
            return unless defined?(@batch_loaders)

            while (_point, batch_loader = batch_loaders.shift)
              batch_loader.load
            end
          end

          private

          def batch_loaders
            @batch_loaders ||= {}.compare_by_identity
          end
        end

        include InstanceMethods
        extend Serega::SeregaHelpers::SerializerClassHelper
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
serega-0.6.1 lib/serega/plugins/batch/lib/loaders.rb
serega-0.6.0 lib/serega/plugins/batch/lib/loaders.rb
serega-0.5.2 lib/serega/plugins/batch/lib/loaders.rb
serega-0.5.1 lib/serega/plugins/batch/lib/loaders.rb
serega-0.5.0 lib/serega/plugins/batch/lib/loaders.rb