Sha256: 039ba90cc1c8f5dc716b1e73ee1b40d440d58953bb5ef3d57ccf2ec83f31d83b

Contents?: true

Size: 730 Bytes

Versions: 16

Compression:

Stored size: 730 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

16 entries across 16 versions & 1 rubygems

Version Path
asynchronic-1.6.3 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.6.2 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.6.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.6.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.5.2 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.5.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.5.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.4.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.3.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.3.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.2.2 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.2.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.2.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.1.1 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.1.0 lib/asynchronic/data_store/lazy_value.rb
asynchronic-1.0.0 lib/asynchronic/data_store/lazy_value.rb