Sha256: ca247cc8f70b24325ba1db7f6341f2660f4d10bdd320cfec6609bf9c7fa9f42d

Contents?: true

Size: 868 Bytes

Versions: 6

Compression:

Stored size: 868 Bytes

Contents

require 'forwardable'

module GameMachine
  module DataStores
    include_package 'org.mapdb'
    class Mapdb
      extend Forwardable

      def_delegators :@client, :get

      def shutdown
        @client.close
      end

      def keys
        @client.keys
      end

      def dump(path,format=:yaml)
        raise NotImplementedError
      end

      def load(path,format=:yaml)
        raise NotImplementedError
      end

      def set(key,value)
        @client.put(key,value)
        @db.commit
      end

      def dbfile
        File.join(GameMachine.app_root,'db','mapdb.db')
      end

      def connect
        unless @client
          @db = DataStores::DBMaker.newFileDB(java.io.File.new(dbfile)).
            closeOnJvmShutdown.
            make
          @client = @db.getTreeMap("entities")
        end
        @client
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
game_machine-1.0.4 lib/game_machine/data_stores/mapdb.rb
game_machine-1.0.2 lib/game_machine/data_stores/mapdb.rb
game_machine-0.0.11 lib/game_machine/data_stores/mapdb.rb
game_machine-0.0.10 lib/game_machine/data_stores/mapdb.rb
game_machine-0.0.9 lib/game_machine/data_stores/mapdb.rb
game_machine-0.0.8 lib/game_machine/data_stores/mapdb.rb