Class: Lookbook::ActionViewAnnotationsHandler

Inherits:
Service
  • Object
show all
Defined in:
lib/lookbook/services/templates/action_view_annotations_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(disable_annotations: true) ⇒ ActionViewAnnotationsHandler

Returns a new instance of ActionViewAnnotationsHandler.



5
6
7
# File 'lib/lookbook/services/templates/action_view_annotations_handler.rb', line 5

def initialize(disable_annotations: true)
  @disable_annotations = disable_annotations
end

Instance Attribute Details

#disable_annotationsObject (readonly)



3
4
5
# File 'lib/lookbook/services/templates/action_view_annotations_handler.rb', line 3

def disable_annotations
  @disable_annotations
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lookbook/services/templates/action_view_annotations_handler.rb', line 9

def call
  if ActionView::Base.respond_to?(:annotate_rendered_view_with_filenames) && disable_annotations
    original_value = ActionView::Base.annotate_rendered_view_with_filenames
    ActionView::Base.annotate_rendered_view_with_filenames = false
    res = yield
    ActionView::Base.annotate_rendered_view_with_filenames = original_value
    res
  else
    yield
  end
end