Sha256: 69a7220de6bc4af66fc2aa6c78c56babe26c2dc832df8a53cd24db2964428e96

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

module Inverter
  module ControllerHelper
    extend ActiveSupport::Concern

    included do
      alias_method_chain :render, :inverter_object
    end


    def render_with_inverter_object(*args, &block)
      # reset Inveter.object to nil
      Inverter.reset_object()

      # make a pointer to meta_tags for future use
      Inverter.set_meta_tags(meta_tags)

      # Call regular render method, this calls custom template rendered which
      # idetifies if there is an inverter object for the template
      render_without_inverter_object(*args, &block)

      # modify response only if Inverter.object is set
      if Inverter.object
        self.response_body[0] = Inverter.object.update_html(self.response_body[0])
      end

      if self.request.format.html?
        self.response_body[0] = Inverter::Tags.update_html(self.response_body[0])
      end
    end
    protected :render_with_inverter_object

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inverter-0.5.1 lib/inverter/controller_helper.rb
inverter-0.5.0 lib/inverter/controller_helper.rb
inverter-0.4.7 lib/inverter/controller_helper.rb
inverter-0.4.6 lib/inverter/controller_helper.rb
inverter-0.4.5 lib/inverter/controller_helper.rb