Sha256: 90acf907b060189b266bb574f6fce3ecbe4203e684d8f15773b67cb95c669500
Contents?: true
Size: 650 Bytes
Versions: 19
Compression:
Stored size: 650 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
19 entries across 19 versions & 1 rubygems