Sha256: bbdb97dace6db559d517ee83acab59116d685b10f34dd8dca1d2e5d32d309218

Contents?: true

Size: 987 Bytes

Versions: 8

Compression:

Stored size: 987 Bytes

Contents

require 'cell/base'

module Cell
  # Use Cell::Rack to mount your cell to a rack-route with a working +session+ and +params+ reference
  # in the cell. This is especially useful when using gems like devise with your cell, without the
  # entire Cell::Rails overhead.
  #
  # The only dependency these kinds of cells have is a Rack-compatible request object.
  #
  # Example:
  #
  #   match "/dashboard/comments" => proc { |env|
  #     request = ActionDispatch::Request.new(env)
  #     [ 200, {}, [ Cell::Rack.render_cell_for(:comments, :show, request) ]]
  #   }
  class Rack < Base
    attr_reader :request
    delegate :session, :params, :to => :request

    class << self
      # DISCUSS: i don't like these class methods. maybe a RenderingStrategy?
      def render_cell_state(cell, state, request, *args) # defined in Rendering.
        super(cell, state, *args)
      end
    end

    def initialize(request, *args)
      super(*args)
      @request = request
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cells-3.11.3 lib/cell/rack.rb
cells-3.11.2 lib/cell/rack.rb
cells-3.11.1 lib/cell/rack.rb
cells-3.11.0 lib/cell/rack.rb
cells-3.10.1 lib/cell/rack.rb
cells-3.10.0 lib/cell/rack.rb
cells-3.9.1 lib/cell/rack.rb
cells-3.9.0 lib/cell/rack.rb