class Xray::Engine
This is the main point of integration with Rails. This engine hooks into Sprockets and monkey patches ActionView in order to augment the app's JS and HTML templates with filepath information that can be used by xray.js in the browser. It also hooks in a middleware responsible for injecting xray.js and the xray bar into the app's response bodies.
Public Instance Methods
ensure_asset_pipeline_enabled!(app)
click to toggle source
# File lib/xray/engine.rb, line 116 def ensure_asset_pipeline_enabled!(app) unless app.assets raise "xray-rails requires the Rails asset pipeline. The asset pipeline is currently disabled in this application. Either convert your application to use the asset pipeline, or remove xray-rails from your Gemfile." end end
render_with_xray(*args, &block)
click to toggle source
# File lib/xray/engine.rb, line 24 def render_with_xray(*args, &block) path = identifier view = args.first source = render_without_xray(*args, &block) suitable_template = !(view.respond_to?(:mailer) && view.mailer) && !path.include?('_xray_bar') && path =~ /\.(html|slim|haml|hamlc)(\.|$)/ && path !~ /\.(js|json|css)(\.|$)/ options = args.last.kind_of?(Hash) ? args.last : {} if source && suitable_template && !(options.has_key?(:xray) && (options[:xray] == false)) Xray.augment_template(source, path) else source end end