Sha256: 92b8914c88992c0fea9f2feba2bb58cbf33087db18cb0e00bafc65892be39f75
Contents?: true
Size: 939 Bytes
Versions: 3
Compression:
Stored size: 939 Bytes
Contents
module CannedTuna class Component include Prawn::View def self.template &block if block_given? @template = block else @template || proc {} end end def draw_in pdf, &block register_outlets(&block) with_temporary_document(pdf) do instance_exec(&self.class.template) end end private def content @content ||= ContentProxy.new end def outlet name = :default, &default_content content.outlet_for(name, &default_content).call end def with_temporary_document pdf @document = pdf yield @document = nil end def register_outlets &block return unless block_given? # Multiple content outlets if block.arity > 0 instance_exec(content, &block) # Default content outlet (short-hand syntax) else content.outlet(:default, &block) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
canned_tuna-0.0.8 | lib/canned_tuna/component.rb |
canned_tuna-0.0.7 | lib/canned_tuna/component.rb |
canned_tuna-0.0.6 | lib/canned_tuna/component.rb |