Class: Hermitage::RailsRenderCore

Inherits:
Object
  • Object
show all
Defined in:
lib/hermitage/rails_render_core.rb

Overview

This class performs all the rendering logic for Rails apps

Instance Method Summary collapse

Constructor Details

#initialize(objects, options = {}) ⇒ RailsRenderCore

Returns a new instance of RailsRenderCore.



6
7
8
9
10
# File 'lib/hermitage/rails_render_core.rb', line 6

def initialize(objects, options = {})
  @objects = objects
  @options = Configurator.options_for(objects, options)
  @template = ActionView::Base.new
end

Instance Method Details

#renderObject

Renders gallery markup



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hermitage/rails_render_core.rb', line 13

def render
  # Initialize the resulting tag
  tag = ''

  # Slice objects into separate lists
  lists = slice_objects

  # Render each list into `tag` variable
  lists.each do |list|
    items = list.collect { |item| render_link_for(item) }
    tag << (items)
  end

  tag.html_safe
end