class Glimpse::Views::View
Public Class Methods
# File lib/glimpse/views/view.rb, line 4 def initialize(options = {}) @options = options setup_subscribers end
Public Instance Methods
Additional context for any view to render tooltips for.
Returns Hash.
# File lib/glimpse/views/view.rb, line 65 def context {} end
# File lib/glimpse/views/view.rb, line 69 def context? context.any? end
The context dom id that is derived from the classname.
Examples:
Glimpse::Views::PerformanceBar => "glimpse-context-performance-bar" Glimpse::Views::Resque => "glimpse-context-resque"
Returns String.
# File lib/glimpse/views/view.rb, line 51 def context_dom_id "glimpse-context-#{defer_key}" end
The defer key that is derived from the classname.
Examples:
Glimpse::Views::PerformanceBar => "performance-bar" Glimpse::Views::Resque => "resque"
Returns String.
# File lib/glimpse/views/view.rb, line 39 def defer_key self.class.to_s.split('::').last.underscore.gsub(/\_/, '-') end
The wrapper ID for the individual view in the Glimpse
bar.
Returns String.
# File lib/glimpse/views/view.rb, line 58 def dom_id "glimpse-view-#{defer_key}" end
Conditionally enable views based on any gathered data. Helpful if you don’t want views to show up when they return 0 or are touched during the request.
Returns true.
# File lib/glimpse/views/view.rb, line 15 def enabled? true end
The path to the partial that will be rendered to the Glimpse
bar.
Examples:
Glimpse::Views::PerformanceBar.partial_path => "glimpse/views/performance_bar" CustomResque.partial_path => "performance_bar"
Returns String.
# File lib/glimpse/views/view.rb, line 27 def partial_path self.class.to_s.underscore end
The data results that are inserted at the end of the request for use in deferred placeholders in the Glimpse
the bar.
Returns Hash.
# File lib/glimpse/views/view.rb, line 77 def results {} end
# File lib/glimpse/views/view.rb, line 81 def results? results.any? end
# File lib/glimpse/views/view.rb, line 85 def subscribe(*args) ActiveSupport::Notifications.subscribe(*args) do |name, start, finish, id, payload| yield name, start, finish, id, payload end end
Private Instance Methods
Helper method for subscribing to the event that is fired when new requests are made.
# File lib/glimpse/views/view.rb, line 99 def before_request subscribe 'start_processing.action_controller' do |name, start, finish, id, payload| yield name, start, finish, id, payload end end
# File lib/glimpse/views/view.rb, line 93 def setup_subscribers # pass end