Sha256: 4001a6dd5128279998e6ac1e8760f7e1f5613ca79893dab3ab4f4b4783e27b68

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require "json"

require "key_vortex/adapter"
require "key_vortex/record"
require "stashify/file"

class KeyVortex
  class Adapter
    class Stashify < KeyVortex::Adapter
      def initialize(stashify)
        super()
        @stashify = stashify
      end

      def save(record)
        @stashify.write(
          ::Stashify::File.new(
            name: record.key,
            contents: JSON.generate(record)
          )
        )
      end

      def find(key)
        return unless @stashify.exists?(key)

        JSON.parse(@stashify.find(key).contents, create_additions: true)
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
key_vortex-stashify-0.1.0 lib/key_vortex/adapter/stashify.rb