Class: CannedTuna::Component

Inherits:
Object
  • Object
show all
Includes:
Prawn::View
Defined in:
lib/canned_tuna/component.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.template(&block) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/canned_tuna/component.rb', line 5

def self.template &block
  if block_given?
    @template = block
  else
    @template || proc {}
  end
end

Instance Method Details

#draw_in(pdf, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/canned_tuna/component.rb', line 13

def draw_in pdf, &block
  register_outlets(&block)

  with_temporary_document(pdf) do
    instance_exec(&self.class.template)
  end
end