Sha256: 562a6c6bf6037895df560a53a6d7d3e044f6fc2a714694dbf4a09fb588116c38
Contents?: true
Size: 1011 Bytes
Versions: 23
Compression:
Stored size: 1011 Bytes
Contents
require 'time' module Tins module TimeDummy def self.included(modul) class << modul alias really_new new alias really_now now remove_method :now rescue nil remove_method :new rescue nil attr_writer :dummy def dummy=(value) if value.respond_to?(:to_str) value = Time.parse(value.to_str) end @dummy = value end def dummy(value = nil) if value.nil? @dummy else begin old_dummy = @dummy self.dummy = value yield ensure self.dummy = old_dummy end end end def new(*a) if dummy dummy.dup elsif caller.first =~ /now/ really_now else really_new(*a) end end def now new end end super end end end require 'tins/alias'
Version data entries
23 entries across 22 versions & 3 rubygems