Sha256: 7c3523117f523bdbd791566c3ad4c462840b395fb708719bbfad36a45d38cb60

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

module Juggalo
  class Page
    attr_reader :components, :template

    def initialize(layout, loader)
      @layout = layout
      @loader = loader
    end

    def compile
      @layout.regions = compose
      @layout.render
    end

    private

    def compose
      @components ||= @loader.load
      @regions    ||= @components.reduce({}) do |regions, component|
        regions.tap do |r|
          if r[component.location].nil?
            r[component.location] = [component]
          else
            r[component.location] << component
          end
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
juggalo-0.0.2 lib/juggalo/page.rb
juggalo-0.0.1 lib/juggalo/page.rb