Sha256: d0f4d7bd45229372e7d24cf1bd08e7c5574c0379090fcd3f20a10fe02fda6ed3

Contents?: true

Size: 564 Bytes

Versions: 33

Compression:

Stored size: 564 Bytes

Contents

require 'time'

module TimeTravel
  module TimeExtensions
  
    def self.included(base)
      base.extend(ClassMethods)
      base.class_eval do
        class << self
          alias_method :immutable_now, :now
          alias_method :now, :mutable_now
        end
      end
      base.now = nil
    end
  
    module ClassMethods

      @@now = nil

      def now=(time)
        time = Time.parse(time) if time.instance_of?(String)
        @@now = time
      end

      def mutable_now #:nodoc:
        @@now || immutable_now
      end
    
    end
  
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
adzap-validates_timeliness-1.1.1 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.2 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.3 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.4 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.5 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.6 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-1.1.7 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-2.0.0 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-2.1.0 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-2.2.0 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-2.2.1 spec/time_travel/time_extensions.rb
adzap-validates_timeliness-2.2.2 spec/time_travel/time_extensions.rb
markos_validates_timeliness-2.3.2.2 spec/time_travel/time_extensions.rb
markos_validates_timeliness-2.3.2.1 spec/time_travel/time_extensions.rb
markos_validates_timeliness-2.3.2 spec/time_travel/time_extensions.rb
validates_timeliness-2.3.2 spec/time_travel/time_extensions.rb
szilm-validates_timeliness-2.3.1 spec/time_travel/time_extensions.rb
validates_timeliness-2.3.1 spec/time_travel/time_extensions.rb
validates_timeliness-2.3.0 spec/time_travel/time_extensions.rb
validates_timeliness-2.2.2 spec/time_travel/time_extensions.rb