Sha256: d96a22e04af4a65c2e12e90d6e97148f6a844cc41dabbe15c07ec531b74e304e

Contents?: true

Size: 696 Bytes

Versions: 1

Compression:

Stored size: 696 Bytes

Contents

require_relative '../transparent_proxy'

module Asynchronic
  module DataStore
    class LazyValue < TransparentProxy

      def initialize(data_store, key)
        @data_store_class = data_store.class
        @data_store_connection = data_store.connection
        @key = key
      end

      def reload
        @value = nil
        self
      end

      def inspect
        "#<#{proxy_class} @data_store_class=#{@data_store_class} @data_store_connection=#{@data_store_connection} @key=#{@key}>"
      end

      def data_store
        @data_store_class.connect @data_store_connection
      end

      private

      def __getobj__
        @value ||= data_store[@key]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asynchronic-0.2.0 lib/asynchronic/data_store/lazy_value.rb