Sha256: e08e48eba8fef31d67a32410579340fe9372681dda2fadde0a577e52e76287e6

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

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

require_relative "renderer"

module PrawnCocktail
  class Document
    def render
      renderer.render_data
    end

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

    def filename
      # Override in your subclass.
    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

1 entries across 1 versions & 1 rubygems

Version Path
prawn_cocktail-0.5.1 lib/prawn_cocktail/document.rb