Sha256: 8d2e3a590719579f9f8d4a0f36d149b6d391dcabc1bc1304557ca5c97d1758b0
Contents?: true
Size: 839 Bytes
Versions: 1
Compression:
Stored size: 839 Bytes
Contents
require 'hoohoo/version' require 'hoohoo/data_store' require 'crimp' module Hoohoo def self.transforms(data, till_midnight = 60) identifier = Crimp.signature(data) cloned_data = deep_copy data transformed = yield cloned_data store({ :id => identifier, :original => data, :transformed => transformed }) check(identifier, till_midnight) identifier end def self.get(id) DataStore.instance.get(id)[:transformed] end def self.midnight(id) reset_data_at(id) end private def self.store(data) DataStore.instance.set(data) end def self.deep_copy(object) Marshal.load(Marshal.dump(object)) end def self.check(id, seconds) Thread.new { sleep seconds; reset_data_at id } end def self.reset_data_at(id) DataStore.instance.reset(id) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hoohoo-0.0.1 | lib/hoohoo.rb |