Sha256: 8829e67149d3d271500269b34cd8c2b03a3cf4d07f234bab244ea5ea2e3eae22
Contents?: true
Size: 617 Bytes
Versions: 1
Compression:
Stored size: 617 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.6.1 | examples/namespacing_keys.rb |