Sha256: 608aa1dd2390639cf5047cd61df4a687efef9fb28434f2d0df2b26c1da12b7c0

Contents?: true

Size: 731 Bytes

Versions: 6

Compression:

Stored size: 731 Bytes

Contents

module Asynchronic
  module DataStore
    class LazyValue < TransparentProxy

      def initialize(data_store, key)
        @data_store_class = data_store.class
        @data_store_connection_args = data_store.connection_args
        @key = key
      end

      def reload
        @value = nil
        self
      end

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

      def data_store
        @data_store_class.connect(*@data_store_connection_args)
      end

      def to_value
        __getobj__
      end

      private

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

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asynchronic-3.0.3 lib/asynchronic/data_store/lazy_value.rb
asynchronic-3.0.2 lib/asynchronic/data_store/lazy_value.rb
asynchronic-3.0.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-3.0.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-2.0.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-2.0.0 lib/asynchronic/data_store/lazy_value.rb