Skip to content

Commit

Permalink
Some REPL Driven Development to fix bug - TODO: fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Feb 21, 2014
1 parent 6eb5f8c commit 7fd905e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'sinderella'

data = { :key => 'value' }
till_midnight = 60

id = Sinderella.transforms(data, till_midnight) do |data|
data.each do |key, value|
data.tap { |d| d[key].upcase! }
end
end

puts Sinderella.get(id)

puts "Resetting data early" and Sinderella.midnight(id) if (rand() * 2).to_i == 1 # randomly reset the data early...

sleep 10

puts Sinderella.get(id)

sleep 60

puts Sinderella.get(id)
2 changes: 1 addition & 1 deletion lib/sinderella.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.deep_copy(object)
end

def self.check(id, seconds)
Thread.new { sleep seconds; reset_data_at id }.join
Thread.new { sleep seconds; reset_data_at id }
end

def self.reset_data_at(id)
Expand Down

0 comments on commit 7fd905e

Please sign in to comment.