lib/tins/date_dummy.rb in tins-1.0.1 vs lib/tins/date_dummy.rb in tins-1.1.0

- old
+ new

@@ -6,28 +6,35 @@ class << modul alias really_today today remove_method :today rescue nil - attr_writer :dummy + def dummy=(value) + if value.respond_to?(:to_str) + value = Date.parse(value.to_str) + end + @dummy = value + end def dummy(value = nil) if value.nil? @dummy else begin old_dummy = @dummy - @dummy = value + self.dummy = value yield ensure - @dummy = old_dummy + self.dummy = old_dummy end end end def today if dummy dummy.dup + elsif caller.first =~ /`today`/ + really_today else really_today end end