Sha256: 6c147f96470ab7028ce508226378b283eed15bef1569e6f2dc9e97d0b77e048f

Contents?: true

Size: 1.39 KB

Versions: 11

Compression:

Stored size: 1.39 KB

Contents

# encoding: utf-8

# These ControllerMethods are automatically added to all Controllers when
# the cells plugin is loaded.
module Cells
  module Rails
    module ActionController
      # Equivalent to ActionController#render_to_string, except it renders a cell
      # rather than a regular templates.
      def render_cell(name, state, opts={})
        cell = ::Cell::Base.create_cell_for(self, name, opts)
        return cell.render_state(state)
      end
      alias_method :render_cell_to_string, :render_cell # just for backward compatibility.

      # Expires the cached cell state view, similar to ActionController::expire_fragment.
      # Usually, this method is used in Sweepers.
      # Beside the obvious first two args <tt>cell_name</tt> and <tt>state</tt> you can pass
      # in additional cache key <tt>args</tt> and cache store specific <tt>opts</tt>.
      #
      # Example:
      #
      #  class ListSweeper < ActionController::Caching::Sweeper
      #   observe List, Item
      #
      #   def after_save(record)
      #     expire_cell_state :my_listing, :display_list
      #   end
      #
      # will expire the view for state <tt>:display_list</tt> in the cell <tt>MyListingCell</tt>.
      def expire_cell_state(cell_name, state, args={}, opts=nil)
        key = ::Cell::Base.cache_key_for(cell_name, state, args)
        ::Cell::Base.expire_cache_key(key, opts)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cells-3.3.10 lib/cells/rails/action_controller.rb
cells-3.3.9 lib/cells/rails/action_controller.rb
cells-3.3.8 lib/cells/rails/action_controller.rb
cells-3.3.7 lib/cells/rails/action_controller.rb
cells-3.3.6 lib/cells/rails/action_controller.rb
cells-3.3.5 lib/cells/rails/action_controller.rb
cells-3.3.4 lib/cells/rails/action_controller.rb
cells-3.3.3 lib/cells/rails/action_controller.rb
cells-3.3.2 lib/cells/rails/action_controller.rb
cells-3.3.1 lib/cells/rails/action_controller.rb
cells-3.3.0 lib/cells/rails/action_controller.rb