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"
LOCALES =
["#{ROOT}/locales"]
LAYOUT =
"#{VIEWS}/layout.erb"
ASSETS =
"#{ROOT}/assets"
DEFAULT_TABS =
{
  "Dashboard" => "",
  "Busy" => "busy",
  "Queues" => "queues",
  "Retries" => "retries",
  "Scheduled" => "scheduled",
  "Dead" => "morgue",
}

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.app_urlObject

Returns the value of attribute app_url.



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

def app_url
  @app_url
end

.localesObject



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

def locales
  @locales ||= LOCALES
end

.redis_poolObject

Returns the value of attribute redis_pool.



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

def redis_pool
  @redis_pool
end

.session_secretObject

Returns the value of attribute session_secret.



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

def session_secret
  @session_secret
end

.sessionsObject

Returns the value of attribute sessions.



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

def sessions
  @sessions
end

.viewsObject



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

def views
  @views ||= VIEWS
end

Instance Attribute Details

#sessionsObject



133
134
135
136
137
138
139
140
# File 'lib/sidekiq/web.rb', line 133

def sessions
  unless instance_variable_defined?("@sessions")
    @sessions = self.class.sessions
    @sessions = @sessions.to_hash.dup if @sessions.respond_to?(:to_hash)
  end

  @sessions
end

Class Method Details

.call(env) ⇒ Object



107
108
109
110
# File 'lib/sidekiq/web.rb', line 107

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

.custom_tabsObject Also known as: tabs



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

def custom_tabs
  @custom_tabs ||= {}
end

.default_tabsObject



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

def default_tabs
  DEFAULT_TABS
end

.disable(*opts) ⇒ Object



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

def disable(*opts)
  opts.each { |key| set(key, false) }
end

.enable(*opts) ⇒ Object



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

def enable(*opts)
  opts.each { |key| set(key, true) }
end

.inherited(child) ⇒ Object



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

def self.inherited(child)
  child.app_url = app_url
  child.session_secret = session_secret
  child.redis_pool = redis_pool
  child.sessions = sessions
end

.middlewaresObject



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

def middlewares
  @middlewares ||= []
end

.register(extension) ⇒ Object



142
143
144
# File 'lib/sidekiq/web.rb', line 142

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…)



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

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

.settingsObject



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

def settings
  self
end

.use(*middleware_args, &block) ⇒ Object



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

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

Instance Method Details

#appObject



112
113
114
# File 'lib/sidekiq/web.rb', line 112

def app
  @app ||= build
end

#call(env) ⇒ Object



103
104
105
# File 'lib/sidekiq/web.rb', line 103

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

#disable(*opts) ⇒ Object



120
121
122
# File 'lib/sidekiq/web.rb', line 120

def disable(*opts)
  opts.each { |key| set(key, false) }
end

#enable(*opts) ⇒ Object



116
117
118
# File 'lib/sidekiq/web.rb', line 116

def enable(*opts)
  opts.each { |key| set(key, true) }
end

#middlewaresObject



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

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

#set(attribute, value) ⇒ Object



124
125
126
# File 'lib/sidekiq/web.rb', line 124

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

#settingsObject



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

def settings
  self.class.settings
end

#use(*middleware_args, &block) ⇒ Object



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

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