Class: Cell::Rails

Inherits:
Rack
  • Object
show all
Includes:
ActionController::RequestForgeryProtection, ActionView::Helpers::UrlHelper, DSL, LinkToHelper
Defined in:
lib/cell/rails/helper_api.rb,
lib/cell/rails.rb,
lib/cell/rails/view_model.rb

Overview

TODO: warn when using ::property but not passing in model in constructor.

Direct Known Subclasses

ViewModel

Defined Under Namespace

Modules: DSL, HelperAPI, LinkToHelper, ViewModel Classes: Builder

Instance Attribute Summary collapse

Attributes inherited from Rack

#request

Attributes included from Caching

#cache_configured

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LinkToHelper

#convert_options_to_data_attributes, #link_to, #link_to_remote_options?

Methods included from DSL

#cell

Methods inherited from Rack

render_cell_state

Methods inherited from Base

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?, #render_state

Methods included from Rendering

#render, #render_state

Constructor Details

#initialize(parent_controller, *args) ⇒ Rails

Returns a new instance of Rails.



41
42
43
44
# File 'lib/cell/rails.rb', line 41

def initialize(parent_controller, *args)
  super(parent_controller, *args) # FIXME: huh?
  @parent_controller = parent_controller
end

Instance Attribute Details

#parent_controllerObject (readonly) Also known as: controller

Returns the value of attribute parent_controller.



38
39
40
# File 'lib/cell/rails.rb', line 38

def parent_controller
  @parent_controller
end

Class Method Details

.cache_storeObject



18
19
20
21
22
23
# File 'lib/cell/rails.rb', line 18

def cache_store
  # FIXME: i'd love to have an initializer in the cells gem that _sets_ the cache_store attr instead of overriding here.
  # since i dunno how to do that we'll have this method in rails for now.
  # DISCUSS: should this be in Cell::Rails::Caching ?
  ActionController::Base.cache_store
end

.cell_for(name, controller, *args) ⇒ Object

Main entry point for instantiating cells.



31
32
33
34
# File 'lib/cell/rails.rb', line 31

def cell_for(name, controller, *args)
  # FIXME: too much redundancy from Base.
  Builder.new(class_from_cell_name(name), controller).call(controller, *args) # use Cell::Rails::Builder.
end

.expire_cache_key(key, *args) ⇒ Object

FIXME: move to Rails.



25
26
27
# File 'lib/cell/rails.rb', line 25

def expire_cache_key(key, *args)  # FIXME: move to Rails.
  expire_cache_key_for(key, cache_store ,*args)
end

Instance Method Details

#cache_configured?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/cell/rails.rb', line 46

def cache_configured?
  ActionController::Base.send(:cache_configured?) # DISCUSS: why is it private?
end

#cache_storeObject



50
51
52
# File 'lib/cell/rails.rb', line 50

def cache_store
  self.class.cache_store  # in Rails, we have a global cache store.
end