Parent

Class/Module Index [+]

Quicksearch

Webgen::SourceHandler::Memory

This source handler should be used for handling nodes that are created during the write phase.

Public Instance Methods

content(node) click to toggle source

Return the content of the memory node. If the memory node was not created in this webgen run, it will be flagged for reinitialization (and therefore recreation).

# File lib/webgen/sourcehandler/memory.rb, line 30
def content(node)
  if @data && @data[node.alcn]
    @data[node.alcn].call
  else
    node.flag(:reinit)
    nil
  end
end
create_node(path, source_alcn, data = nil) click to toggle source

Create a node for the path. The source_alcn specifies the node that creates this memory node when written. You have two options for providing the content for this node: either you set data to a string (or a Webgen::Path::SourceIO object) or you provide a block which takes the created node as argument and returns a string (or a Webgen::Path::SourceIO object).

# File lib/webgen/sourcehandler/memory.rb, line 21
def create_node(path, source_alcn, data = nil)
  super(path) do |node|
    node.node_info[:memory_source_alcn] = source_alcn
    (@data ||= {})[node.alcn] = lambda { data || yield(node) }
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.