Sha256: dfe5fa632641485b76434bb086c23939738d05982941d65246430f708b8746dc

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Web
    module Helpers
      VIEW_PATH = File.expand_path('../web/views', __dir__)

      def unique_template(name)
        File.open(File.join(VIEW_PATH, "#{name}.erb")).read
      end

      def redirect_to(subpath)
        if respond_to?(:to)
          # Sinatra-based web UI
          redirect to(subpath)
        else
          # Non-Sinatra based web UI (Sidekiq 4.2+)
          redirect "#{root_path}#{subpath}"
        end
      end

      def safe_relative_time(time)
        time = if time.is_a?(Numeric)
                 Time.at(time)
               else
                 Time.parse(time)
               end

        relative_time(time)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-6.0.1 lib/sidekiq_unique_jobs/web/helpers.rb