Class: Sidekiq::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/web.rb

Constant Summary collapse

ROOT =
File.expand_path("#{File.dirname(__FILE__)}/../../web")
VIEWS =
"#{ROOT}/views".freeze
LOCALES =
["#{ROOT}/locales".freeze]
LAYOUT =
"#{VIEWS}/layout.erb".freeze
ASSETS =
"#{ROOT}/assets".freeze
DEFAULT_TABS =
{
  "Dashboard" => '',
  "Busy"      => 'busy',
  "Queues"    => 'queues',
  "Retries"   => 'retries',
  "Scheduled" => 'scheduled',
  "Dead"      => 'morgue',
}

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.app_urlObject

Returns the value of attribute app_url.



71
72
73
# File 'lib/sidekiq/web.rb', line 71

def app_url
  @app_url
end

.localesObject



58
59
60
# File 'lib/sidekiq/web.rb', line 58

def locales
  @locales ||= LOCALES
end

.redis_poolObject

Returns the value of attribute redis_pool.



71
72
73
# File 'lib/sidekiq/web.rb', line 71

def redis_pool
  @redis_pool
end

.session_secretObject

Returns the value of attribute session_secret.



71
72
73
# File 'lib/sidekiq/web.rb', line 71

def session_secret
  @session_secret
end

.viewsObject



62
63
64
# File 'lib/sidekiq/web.rb', line 62

def views
  @views ||= VIEWS
end

Class Method Details

.call(env) ⇒ Object



91
92
93
94
# File 'lib/sidekiq/web.rb', line 91

def self.call(env)
  @app ||= new
  @app.call(env)
end

.custom_tabsObject Also known as: tabs



53
54
55
# File 'lib/sidekiq/web.rb', line 53

def custom_tabs
  @custom_tabs ||= {}
end

.default_tabsObject



49
50
51
# File 'lib/sidekiq/web.rb', line 49

def default_tabs
  DEFAULT_TABS
end

.middlewaresObject



41
42
43
# File 'lib/sidekiq/web.rb', line 41

def middlewares
  @middlewares ||= []
end

.register(extension) ⇒ Object



100
101
102
# File 'lib/sidekiq/web.rb', line 100

def self.register(extension)
  extension.registered(WebApplication)
end

.set(attribute, value) ⇒ Object

Helper for the Sinatra syntax: Sidekiq::Web.set(:session_secret, Rails.application.secrets…)



67
68
69
# File 'lib/sidekiq/web.rb', line 67

def set(attribute, value)
  send(:"#{attribute}=", value)
end

.settingsObject



37
38
39
# File 'lib/sidekiq/web.rb', line 37

def settings
  self
end

.use(*middleware_args, &block) ⇒ Object



45
46
47
# File 'lib/sidekiq/web.rb', line 45

def use(*middleware_args, &block)
  middlewares << [middleware_args, block]
end

Instance Method Details

#appObject



96
97
98
# File 'lib/sidekiq/web.rb', line 96

def app
  @app ||= build
end

#call(env) ⇒ Object



87
88
89
# File 'lib/sidekiq/web.rb', line 87

def call(env)
  app.call(env)
end

#middlewaresObject



83
84
85
# File 'lib/sidekiq/web.rb', line 83

def middlewares
  @middlewares ||= Web.middlewares.dup
end

#settingsObject



75
76
77
# File 'lib/sidekiq/web.rb', line 75

def settings
  self.class.settings
end

#use(*middleware_args, &block) ⇒ Object



79
80
81
# File 'lib/sidekiq/web.rb', line 79

def use(*middleware_args, &block)
  middlewares << [middleware_args, block]
end