Module: SidekiqUniqueJobs::Web::Helpers
- Defined in:
- lib/sidekiq_unique_jobs/web/helpers.rb
Constant Summary collapse
- VIEW_PATH =
File.('../web/views', __dir__)
Instance Method Summary collapse
- #filtering(pattern, count) ⇒ Object
- #redirect_to(subpath) ⇒ Object
- #safe_relative_time(time) ⇒ Object
- #unique_template(name) ⇒ Object
Instance Method Details
#filtering(pattern, count) ⇒ Object
8 9 10 |
# File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 8 def filtering(pattern, count) SidekiqUniqueJobs::Util.keys(pattern, count) end |
#redirect_to(subpath) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 16 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 |
#safe_relative_time(time) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 26 def safe_relative_time(time) time = if time.is_a?(Numeric) Time.at(time) else Time.parse(time) end relative_time(time) end |
#unique_template(name) ⇒ Object
12 13 14 |
# File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 12 def unique_template(name) File.open(File.join(VIEW_PATH, "#{name}.erb")).read end |