Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
clock / lib / clock / substitute.rb
Size: Mime:
module Clock
  class Substitute
    include Clock

    attr_writer :system_time

    def system_time
      @system_time ||= NullTime.build
    end

    def now=(val)
      system_time = OpenStruct.new
      system_time.now = val
      self.system_time = system_time
      system_time
    end

    def iso8601(*args)
      if system_time.is_a? OpenStruct
        return super(*args)
      end
      nil
    end

    class NullTime < Naught.build
      def self.build
        new
      end
    end
  end
end