Class: Tuning::Extensions::ActionView::Handlers::Ruby

Inherits:
Object
  • Object
show all
Defined in:
lib/tuning/extensions/action_view/handlers.rb

Instance Method Summary collapse

Instance Method Details

#call(template) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tuning/extensions/action_view/handlers.rb', line 9

def call(template)
  if template.type.json?
    if File.basename(template.identifier).starts_with?('_')
      template.source
    else
      <<~STRING
        output = begin
          #{template.source}
        end
        if output.is_a?(String)
          output
        else
          output.to_json
        end
      STRING
    end
  else
    template.source
  end
end