module GlassSlippers

Constants

VERSION

Public Class Methods

get(id) click to toggle source
# File lib/glass_slippers.rb, line 22
def self.get(id)
      DataStore.instance.get(id)[:transformed]
end
midnight(id) click to toggle source
# File lib/glass_slippers.rb, line 26
def self.midnight(id)
  reset_data_at(id)
end
transforms(data, till_midnight = 60) { |cloned_data| ... } click to toggle source
# File lib/glass_slippers.rb, line 6
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

Private Class Methods

check(id, seconds) click to toggle source
# File lib/glass_slippers.rb, line 40
def self.check(id, seconds)
  Thread.new { sleep seconds; reset_data_at id }
end
deep_copy(object) click to toggle source
# File lib/glass_slippers.rb, line 36
def self.deep_copy(object)
      Marshal.load(Marshal.dump(object))
end
reset_data_at(id) click to toggle source
# File lib/glass_slippers.rb, line 44
def self.reset_data_at(id)
  DataStore.instance.reset(id)
end
store(data) click to toggle source
# File lib/glass_slippers.rb, line 32
def self.store(data)
      DataStore.instance.set(data)
end