class Camcorder::Recording
Attributes
behavior[R]
value[R]
Public Class Methods
new(&block)
click to toggle source
# File lib/camcorder/recording.rb, line 8 def initialize(&block) @value = nil @behavior = nil end
Public Instance Methods
==(other)
click to toggle source
# File lib/camcorder/recording.rb, line 39 def ==(other) YAML.dump(self) == YAML.dump(other) end
deep_clone(value)
click to toggle source
# File lib/camcorder/recording.rb, line 35 def deep_clone(value) YAML.load(YAML.dump(value)) end
record() { || ... }
click to toggle source
# File lib/camcorder/recording.rb, line 13 def record(&block) res = yield # Make sure we store a copy of the result so future destructive mutations # do not change this value @value = deep_clone(res) @behavior = :return res rescue Exception => e @value = e @behavior = :raise raise e end
replay()
click to toggle source
# File lib/camcorder/recording.rb, line 26 def replay case @behavior when :return return @value when :raise raise @value end end