Sha256: dd929db108745ae1c5a3372cb5ed56378062511980c4394868d100375972486e
Contents?: true
Size: 712 Bytes
Versions: 12
Compression:
Stored size: 712 Bytes
Contents
require 'cap-util/timer' module CapUtil def self.time(timer_set, name, &block) timer_set[name] ||= CapUtil::Timer.new(name) if !block.nil? begin timer_set[name].start block.call ensure timer_set[name].end end end timer_set[name] end module Time def self.included(receiver) receiver.send(:extend, ClassMethods) receiver.send(:include, InstanceMethods) end module ClassMethods def time(*args, &block); CapUtil.time(*args, &block); end end module InstanceMethods def time(name, &block) @cap_util_timers ||= {} CapUtil.time(@cap_util_timers, name, &block) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems