Module: Papercraft::ProcExtensions

Defined in:
lib/papercraft/proc_ext.rb

Overview

Extensions to the Proc class.

Instance Method Summary collapse

Instance Method Details

#__papercraft_compiled!self

Marks the proc as compiled, i.e. can render directly and takes a string buffer as first argument.

Returns:

  • (self)


19
20
21
22
# File 'lib/papercraft/proc_ext.rb', line 19

def __papercraft_compiled!
  @__papercraft_compiled = true
  self
end

#__papercraft_compiled?bool

Returns true if proc is marked as compiled.

Returns:

  • (bool)

    is the proc marked as compiled



11
12
13
# File 'lib/papercraft/proc_ext.rb', line 11

def __papercraft_compiled?
  @__papercraft_compiled
end

#__papercraft_compiled_proc(mode: :html) ⇒ Proc

Returns the compiled proc for the proc. If marked as compiled, returns self.

Parameters:

  • mode (Symbol) (defaults to: :html)

    compilation mode (:html, :xml)

Returns:

  • (Proc)

    compiled proc or self



29
30
31
32
# File 'lib/papercraft/proc_ext.rb', line 29

def __papercraft_compiled_proc(mode: :html)
  @__papercraft_compiled_proc ||= @__papercraft_compiled ?
    self : Papercraft.compile(self, mode:)
end

#__papercraft_render_cacheHash

Returns the render cache for the proc.

Returns:

  • (Hash)

    cache hash



37
38
39
# File 'lib/papercraft/proc_ext.rb', line 37

def __papercraft_render_cache
  @__papercraft_render_cache ||= {}
end