Module: Cell::ViewModel::Helpers

Included in:
Cell::ViewModel
Defined in:
lib/cell/view_model.rb

Instance Method Summary collapse

Instance Method Details

#cell(name, controller, *args, &block) ⇒ Object

TODO: this should be in Helper or something. this should be the only entry point from controller/view.



28
29
30
31
32
33
34
# File 'lib/cell/view_model.rb', line 28

def cell(name, controller, *args, &block) # classic Rails fuzzy API.
  if args.first.is_a?(Hash) and array = args.first[:collection]
    return collection(name, controller, array)
  end

  cell_for(name, controller, *args, &block)
end

#collection(name, controller, array, method = :show) ⇒ Object

DISCUSS: highest level API method. add #cell here.



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

def collection(name, controller, array, method=:show)
  # FIXME: this is the problem in Concept cells, we don't wanna call Cell::Rails.cell_for here.
  array.collect { |model| cell_for(name, controller, model).call(method) }.join("\n").html_safe
end