Class: Cell::Rack

Inherits:
Base
  • Object
show all
Defined in:
lib/cell/rack.rb

Overview

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) ]]
}

Direct Known Subclasses

Rails

Instance Attribute Summary collapse

Attributes included from Caching

#cache_configured, #cache_store

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

cell_for, class_from_cell_name

Methods included from Builder::ClassMethods

#build, #builders

Methods included from Base::SelfContained

#self_contained!

Methods included from Base::Prefixes

#_prefixes

Methods included from DSL

#cell

Methods included from Caching

#cache?, #cache_configured?, #render_state

Methods included from Rendering

#render, #render_state

Constructor Details

#initialize(request, *args) ⇒ Rack

Returns a new instance of Rack.



27
28
29
30
# File 'lib/cell/rack.rb', line 27

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

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



17
18
19
# File 'lib/cell/rack.rb', line 17

def request
  @request
end

Class Method Details

.render_cell_state(cell, state, request, *args) ⇒ Object

DISCUSS: i don’t like these class methods. maybe a RenderingStrategy?



22
23
24
# File 'lib/cell/rack.rb', line 22

def render_cell_state(cell, state, request, *args) # defined in Rendering.
  super(cell, state, *args)
end