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


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

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


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

def redis_pool
  @redis_pool
end

.session_secretObject

Returns the value of attribute session_secret


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

def session_secret
  @session_secret
end

.sessionsObject

Returns the value of attribute sessions


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

def sessions
  @sessions
end

.viewsObject


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

def views
  @views ||= VIEWS
end

Instance Attribute Details

#sessionsObject


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

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


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

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

.disable(*opts) ⇒ Object


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

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

.enable(*opts) ⇒ Object


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

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

.inherited(child) ⇒ Object


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

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

.middlewaresObject


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

def middlewares
  @middlewares ||= []
end

.register(extension) ⇒ Object


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

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


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

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


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

def app
  @app ||= build
end

#call(env) ⇒ Object


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

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

#disable(*opts) ⇒ Object


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

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

#enable(*opts) ⇒ Object


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

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

#middlewaresObject


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

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

#set(attribute, value) ⇒ Object


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

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

#settingsObject


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

def settings
  self.class.settings
end

#use(*middleware_args, &block) ⇒ Object


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

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