class Integral::PartialListItemRenderer
Allow list items to be renderered through a partial
Public Class Methods
new(list_item, opts = {})
click to toggle source
Calls superclass method
Integral::ListItemRenderer::new
# File lib/integral/partial_list_item_renderer.rb, line 4 def initialize(list_item, opts = {}) super raise_if_partial_path_missing end
Public Instance Methods
render_item()
click to toggle source
Override Integral::ListItemRenderer#render_item
# File lib/integral/partial_list_item_renderer.rb, line 11 def render_item partial_opts = { title: title, subtitle: subtitle, description: description, url: url, image: image(@opts[:image_version]), type: list_item.type, object: object_available? ? list_item.object.decorate : nil } controller.render partial: @opts[:partial_path], locals: partial_opts, layout: false end
Private Instance Methods
controller()
click to toggle source
# File lib/integral/partial_list_item_renderer.rb, line 34 def controller return @opts[:controller] if @opts[:controller].present? ApplicationController end
raise_if_partial_path_missing()
click to toggle source
# File lib/integral/partial_list_item_renderer.rb, line 27 def raise_if_partial_path_missing return if @opts[:partial_path].present? error_msg = 'PartialListItemRenderer requires the partial_path (pass this in via opts hash)' raise ArgumentError, error_msg end