Class: Peek::Views::View
- Inherits:
-
Object
- Object
- Peek::Views::View
- Defined in:
- lib/peek/views/view.rb
Instance Method Summary collapse
-
#context ⇒ Object
Additional context for any view to render tooltips for.
- #context? ⇒ Boolean
-
#context_id ⇒ Object
The context id that is derived from the classname.
-
#dom_id ⇒ Object
The wrapper ID for the individual view in the Peek bar.
-
#enabled? ⇒ Boolean
Conditionally enable views based on any gathered data.
-
#initialize(options = {}) ⇒ View
constructor
A new instance of View.
-
#key ⇒ Object
(also: #defer_key)
The defer key that is derived from the classname.
-
#parse_options ⇒ Object
Where any subclasses should pick and pull from @options to set any and all instance variables they like.
-
#partial_path ⇒ Object
The path to the partial that will be rendered to the Peek bar.
-
#results ⇒ Object
The data results that are inserted at the end of the request for use in deferred placeholders in the Peek the bar.
- #results? ⇒ Boolean
- #subscribe(*args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ View
Returns a new instance of View.
4 5 6 7 8 9 |
# File 'lib/peek/views/view.rb', line 4 def initialize( = {}) @options = setup_subscribers end |
Instance Method Details
#context ⇒ Object
Additional context for any view to render tooltips for.
Returns Hash.
75 76 77 |
# File 'lib/peek/views/view.rb', line 75 def context {} end |
#context? ⇒ Boolean
79 80 81 |
# File 'lib/peek/views/view.rb', line 79 def context? context.any? end |
#context_id ⇒ Object
61 62 63 |
# File 'lib/peek/views/view.rb', line 61 def context_id "peek-context-#{key}" end |
#dom_id ⇒ Object
The wrapper ID for the individual view in the Peek bar.
Returns String.
68 69 70 |
# File 'lib/peek/views/view.rb', line 68 def dom_id "peek-view-#{key}" end |
#enabled? ⇒ Boolean
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.
24 25 26 |
# File 'lib/peek/views/view.rb', line 24 def enabled? true end |
#key ⇒ Object Also known as: defer_key
48 49 50 |
# File 'lib/peek/views/view.rb', line 48 def key self.class.to_s.split('::').last.underscore.gsub(/\_/, '-') end |
#parse_options ⇒ Object
Where any subclasses should pick and pull from @options to set any and all instance variables they like.
Returns nothing.
15 16 17 |
# File 'lib/peek/views/view.rb', line 15 def # pass end |
#partial_path ⇒ Object
36 37 38 |
# File 'lib/peek/views/view.rb', line 36 def partial_path self.class.to_s.underscore end |
#results ⇒ Object
The data results that are inserted at the end of the request for use in deferred placeholders in the Peek the bar.
Returns Hash.
87 88 89 |
# File 'lib/peek/views/view.rb', line 87 def results {} end |
#results? ⇒ Boolean
91 92 93 |
# File 'lib/peek/views/view.rb', line 91 def results? results.any? end |
#subscribe(*args) ⇒ Object
95 96 97 98 99 |
# File 'lib/peek/views/view.rb', line 95 def subscribe(*args) ActiveSupport::Notifications.subscribe(*args) do |name, start, finish, id, payload| yield name, start, finish, id, payload end end |