Sha256: f4e49105f9e8d5a5e29cb6df75126e23d07d28e84ddd4bce87d812c4a0c0785a

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

require "key_vortex"
require "key_vortex/adapter"

class KeyVortex
  class Adapter
    class Memory < KeyVortex::Adapter
      def self.build(items: {}, limitations: [])
        new(items, limitations: limitations)
      end

      def initialize(items, limitations: [])
        super()
        @items = items
        limitations.each { |limit| register_limitation(limit) }
      end

      def save(record)
        @items[record.key] = record
      end

      def find(id)
        @items[id]
      end

      def remove(key)
        @items.delete(key)
      end
    end
  end
end

KeyVortex.register(KeyVortex::Adapter::Memory)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
key-vortex-0.2.5 lib/key_vortex/adapter/memory.rb
key-vortex-0.2.4 lib/key_vortex/adapter/memory.rb
key-vortex-0.2.3 lib/key_vortex/adapter/memory.rb