Module: Cell::Rails::ViewModel

Extended by:
ActiveSupport::Concern, Helpers
Includes:
ActionView::Context, OptionsConstructor
Defined in:
lib/cell/rails/view_model.rb

Defined Under Namespace

Modules: ClassMethods, Helpers

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

collection

Instance Attribute Details

#modelObject (readonly)

properties :title, :body



15
16
17
# File 'lib/cell/rails/view_model.rb', line 15

def model
  @model
end

Class Method Details

.includedObject



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

def self.included(*)
  ActiveSupport::Deprecation.warn("The Cell::Rails::ViewModel module is deprecated and will be removed in Cells 4.0. Please inherit: `class SongCell < Cell::ViewModel`. Thanks and don't forget to smile.")
  super
end

Instance Method Details

#call(state = :show) ⇒ Object



74
75
76
77
78
# File 'lib/cell/rails/view_model.rb', line 74

def call(state=:show)
  # it is ok to call to_s.html_safe here as #call is a defined rendering method.
  # DISCUSS: IN CONCEPT: render( view: implicit_state)
  render_state(state).to_s.html_safe
end

#cell(name, *args) ⇒ Object



54
55
56
# File 'lib/cell/rails/view_model.rb', line 54

def cell(name, *args)
  self.class.cell(name, parent_controller, *args)
end

#initialize(*args) ⇒ Object



59
60
61
62
# File 'lib/cell/rails/view_model.rb', line 59

def initialize(*args)
  super
  _prepare_context # happens in AV::Base at the bottom.
end

#render(options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/cell/rails/view_model.rb', line 64

def render(options={})
  if options.is_a?(Hash)
    options.reverse_merge!(:view => state_for_implicit_render)
  else
    options = {:view => options.to_s}
  end

  super
end