Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (16 sloc) 426 Bytes
require 'hashback'
require 'uuid'
class Elephant
HashBack::Resource.setup(self, :uuid, 'Moneta::Memory')
attr_accessor :uuid, :name
def initialize(name)
@name = name
@uuid = UUID.new.generate
end
end
dumbo = Elephant.new('Dumbo')
dumbo.save
# And later, when you want to bring Dumbo back...
new_dumbo = Elephant.fetch(dumbo.uuid)
# When you're sick of Dumbo and just want him gone:
new_dumbo.destroy
Jump to Line
Something went wrong with that request. Please try again.