Method: Cell::ViewModel.call

Defined in:
lib/cell/view_model.rb

.call(model = nil, options = {}, &block) ⇒ Object

Public entry point. Use this to instantiate cells with builders.

SongCell.(@song)
SongCell.(collection: Song.all)


47
48
49
50
51
52
53
# File 'lib/cell/view_model.rb', line 47

def call(model=nil, options={}, &block)
  if model.is_a?(Hash) and array = model[:collection]
    return Collection.new(array, model.merge(options), self)
  end

  build(model, options)
end