Sha256: 0b20234f0d38049c68cacb3935853c70fb6d2b6962d88843cd2055d9fb28d2c7
Contents?: true
Size: 651 Bytes
Versions: 2
Compression:
Stored size: 651 Bytes
Contents
require 'pp' require 'rubygems' require 'pathname' root_path = Pathname(__FILE__).dirname.join('..').expand_path lib_path = root_path.join('lib') $:.unshift(lib_path) require 'toystore' class NamespacedUUIDKeyFactory < Toy::Identity::AbstractKeyFactory def key_type String end def next_key(object) [object.class.name, SimpleUUID::UUID.new.to_guid].join(':') end end class User include Toy::Store key NamespacedUUIDKeyFactory.new end puts User.new.id # User:some_uuid # or use namespaces for all classes Toy.key_factory = NamespacedUUIDKeyFactory.new class Game include Toy::Store end puts Game.new.id # Game:some_uuid
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.13.2 | examples/namespacing_keys.rb |
toystore-0.13.1 | examples/namespacing_keys.rb |