Class: Rack::Bug

Inherits:
Object
  • Object
show all
Includes:
Options
Defined in:
lib/rack/bug/panel.rb,
lib/rack/bug/render.rb,
lib/rack/bug/options.rb,
lib/rack/bug/toolbar.rb,
lib/rack/bug/panel_app.rb,
lib/rack/bug/autoloading.rb,
lib/rack/bug/panels/log_panel.rb,
lib/rack/bug/panels/sql_panel.rb,
lib/rack/bug/params_signature.rb,
lib/rack/bug/filtered_backtrace.rb,
lib/rack/bug/panels/cache_panel.rb,
lib/rack/bug/panels/redis_panel.rb,
lib/rack/bug/panels/timer_panel.rb,
lib/rack/bug/panels/memory_panel.rb,
lib/rack/bug/panels/sphinx_panel.rb,
lib/rack/bug/redirect_interceptor.rb,
lib/rack/bug/panels/sql_panel/query.rb,
lib/rack/bug/panels/templates_panel.rb,
lib/rack/bug/panels/rails_info_panel.rb,
lib/rack/bug/rack_static_bug_avoider.rb,
lib/rack/bug/panels/cache_panel/stats.rb,
lib/rack/bug/panels/redis_panel/stats.rb,
lib/rack/bug/panels/sphinx_panel/stats.rb,
lib/rack/bug/panels/active_record_panel.rb,
lib/rack/bug/panels/sql_panel/panel_app.rb,
lib/rack/bug/panels/cache_panel/panel_app.rb,
lib/rack/bug/panels/templates_panel/trace.rb,
lib/rack/bug/panels/request_variables_panel.rb,
lib/rack/bug/panels/templates_panel/rendering.rb,
lib/rack/bug.rb

Defined Under Namespace

Modules: FilteredBacktrace, LoggerExtension, Options, Render Classes: ActiveRecordPanel, CachePanel, LogPanel, MemoryPanel, Panel, PanelApp, ParamsSignature, RackStaticBugAvoider, RailsInfoPanel, RedirectInterceptor, RedisPanel, RequestVariablesPanel, SQLPanel, SecurityError, SphinxPanel, TemplatesPanel, TimerPanel, Toolbar

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Options

#options, #options=, #set

Constructor Details

#initialize(app, options = {}, &block) ⇒ Bug

Returns a new instance of Bug.



27
28
29
30
31
32
33
# File 'lib/rack/bug.rb', line 27

def initialize(app, options = {}, &block)
  @app = asset_server(app)
  initialize_options options
  instance_eval(&block) if block_given?
  
  @toolbar = Toolbar.new(RedirectInterceptor.new(@app))
end

Class Method Details

.disableObject



19
20
21
# File 'lib/rack/bug.rb', line 19

def self.disable
  Thread.current["rack-bug.enabled"] = false
end

.enableObject



15
16
17
# File 'lib/rack/bug.rb', line 15

def self.enable
  Thread.current["rack-bug.enabled"] = true
end

.enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rack/bug.rb', line 23

def self.enabled?
  Thread.current["rack-bug.enabled"] == true
end

Instance Method Details

#call(env) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rack/bug.rb', line 36

def call(env)
  env.replace @default_options.merge(env)
  @env = env
  @original_request = Rack::Request.new(@env)

  if toolbar_requested? && ip_authorized? && password_authorized? && toolbar_xhr?
    @toolbar.call(env)
  else
    @app.call(env)
  end
end