Sha256: 1e1553221cef5576ae737e50c58c0dbc176527c5e2c829100e0f185ebbdbb0ab

Contents?: true

Size: 1.07 KB

Versions: 16

Compression:

Stored size: 1.07 KB

Contents

begin
  require 'thread_safe'
rescue LoadError
  raise LoadError, 'Please install the `thread_safe` gem.'
end

require 'rom/memory/dataset'

module ROM
  module Memory
    # In-memory thread-safe data storage
    #
    # @private
    class Storage
      # Dataset registry
      #
      # @return [ThreadSafe::Hash]
      #
      # @api private
      attr_reader :data

      # @api private
      def initialize
        @data = ThreadSafe::Hash.new
      end

      # @return [Dataset]
      #
      # @api private
      def [](name)
        data[name]
      end

      # Register a new dataset
      #
      # @return [Dataset]
      #
      # @api private
      def create_dataset(name)
        data[name] = Dataset.new(ThreadSafe::Array.new)
      end

      # Check if there's dataset under specified key
      #
      # @return [Boolean]
      #
      # @api private
      def key?(name)
        data.key?(name)
      end

      # Return registered datasets count
      #
      # @return [Integer]
      #
      # @api private
      def size
        data.size
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rom-1.0.0 lib/rom/memory/storage.rb
rom-1.0.0.rc1 lib/rom/memory/storage.rb
rom-1.0.0.beta2 lib/rom/memory/storage.rb
rom-1.0.0.beta1 lib/rom/memory/storage.rb
rom-0.9.1 lib/rom/memory/storage.rb
rom-0.9.0 lib/rom/memory/storage.rb
rom-0.9.0.rc1 lib/rom/memory/storage.rb
rom-0.9.0.beta1 lib/rom/memory/storage.rb
rom-0.8.1 lib/rom/memory/storage.rb
rom-0.8.0 lib/rom/memory/storage.rb
rom-0.7.1 lib/rom/memory/storage.rb
rom-0.7.0 lib/rom/memory/storage.rb
rom-0.6.2 lib/rom/memory/storage.rb
rom-0.6.1 lib/rom/memory/storage.rb
rom-0.6.0 lib/rom/memory/storage.rb
rom-0.6.0.rc1 lib/rom/memory/storage.rb