Module: Cell::ViewModel::Rendering

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

Instance Method Summary collapse

Instance Method Details

#call(state = :show, *args) {|_self| ... } ⇒ Object

Invokes the passed method (defaults to :show) while respecting caching. In Rails, the return value gets marked html_safe.

Yields self to an optional block.

Yields:

  • (_self)

Yield Parameters:



102
103
104
105
106
107
# File 'lib/cell/view_model.rb', line 102

def call(state=:show, *args)
  content = render_state(state, *args)
  yield self if block_given?

  content.to_s
end

#render(options = {}) ⇒ Object

render :show



110
111
112
113
# File 'lib/cell/view_model.rb', line 110

def render(options={})
  options = normalize_options(options, caller) # TODO: call render methods with call(:show), call(:comments) instead of directly #comments?
  render_to_string(options)
end