Module: ActionView::Rendering

Defined in:
lib/lolita-editable-list.rb

Overview

Action View Rendering

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



18
19
20
21
22
# File 'lib/lolita-editable-list.rb', line 18

def self.included(mod)
  mod.class_eval do
    alias_method_chain :render, :lolita_editable
  end
end

Instance Method Details

#render_with_lolita_editable(options = {}, locals = {}, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lolita-editable-list.rb', line 24

def render_with_lolita_editable(options = {}, locals = {}, &block)
  if defined?(lolita_mapping)
    model = lolita_mapping.class_name.constantize
    if model.lolita.list.editable?
      if options[:partial] =~ /^\/components\/lolita\/list\/([a-z_]+)$/
        if %w(body_cell display row).include?($1)
          options[:partial] = "/components/lolita/list/editable/#{$1}"
        end
      end
    end
  end
  render_without_lolita_editable(options, locals, &block)
end