Module: Lytix::ControllerMethods::InstanceMethods

Defined in:
lib/lytix/controller_methods.rb

Instance Method Summary collapse

Instance Method Details

#google_analytics(options = {}) ⇒ Object



23
24
25
26
# File 'lib/lytix/controller_methods.rb', line 23

def google_analytics(options = {})
  @google_analytics = Snippet.new(options).to_s
  nil
end

#insert_google_analyticsObject



28
29
30
31
32
33
# File 'lib/lytix/controller_methods.rb', line 28

def insert_google_analytics
  if @google_analytics && request.format.html? && response.body.respond_to?(:sub!)
    response.body.sub!(/([ \t]*)<\/body>/i){ [($1 + @google_analytics.to_s), $&].join($/) }
  end
  nil
end