Sha256: eca75b8aa15920db3cf4cd5965e017fce751111a9d32467de58bf120af29a40d

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 Bytes

Contents

require "alephant/lookup/lookup_table"
require "alephant/lookup/lookup_query"

require 'alephant/logger'

module Alephant
  module Lookup
    class LookupHelper
      include Logger

      attr_reader :lookup_table

      def initialize(lookup_table)
        logger.info "LookupHelper#initialize(#{lookup_table.table_name})"

        @lookup_table = lookup_table
      end

      def read(id, opts, batch_version)
        logger.info "LookupHelper#read(#{id}, #{opts}, #{batch_version})"

        LookupQuery.new(lookup_table.table_name, id, opts, batch_version).run!
      end

      def write(id, opts, batch_version, location)
        logger.info "LookupHelper#write(#{id}, #{opts}, #{batch_version}, #{location})"

        LookupLocation.new(id, opts, batch_version, location).tap do |l|
          lookup_table.write(
            l.component_key,
            l.batch_version,
            l.location
          )
        end
      end

      def truncate!
        @lookup_table.truncate!
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-lookup-0.4.2 lib/alephant/lookup/lookup_helper.rb
alephant-lookup-0.4.1 lib/alephant/lookup/lookup_helper.rb