Sha256: bdc4b0b43aec78c40f13479c8a09f27271d7b0a141e662bcbdc6d627b8bb51a3

Contents?: true

Size: 479 Bytes

Versions: 3

Compression:

Stored size: 479 Bytes

Contents

module Spruz
  module TimeDummy
    def self.included(modul)
      modul.module_eval do
        class << self
          alias really_new new
          remove_method :now rescue nil
          remove_method :new rescue nil
        end

        extend ClassMethods
      end
    end

    module ClassMethods
      attr_accessor :dummy

      def new
        if dummy
          dummy.dup
        else
          really_new
        end
      end

      alias now new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spruz-0.2.13 lib/spruz/time_dummy.rb
spruz-0.2.12 lib/spruz/time_dummy.rb
spruz-0.2.11 lib/spruz/time_dummy.rb