Sha256: f7c6dab993e1d1d129407c88a354890c5149a9e2d18be2e44e87daadb28bbdcb

Contents?: true

Size: 672 Bytes

Versions: 2

Compression:

Stored size: 672 Bytes

Contents

require "prawn"
require "active_support/core_ext/class/attribute"

require_relative "renderer"

module PrawnCocktail
  class Document
    def render
      renderer.render_data
    end

    def render_file(file)
      renderer.render_file(file)
    end

    private

    def renderer
      @renderer ||= Renderer.new(template, data, self.class.doc_initializers)
    end

    def template
      self.class.name.underscore
    end

    class_attribute :doc_initializers
    self.doc_initializers ||= []

    def self.initialize_document(&block)
      self.doc_initializers << block
    end

    def self.helper(mod)
      initialize_document { extend mod }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prawn_cocktail-0.2.0 lib/prawn_cocktail/document.rb
prawn_cocktail-0.0.1 lib/prawn_cocktail/document.rb