Buildable
Buildable is mixin variation of BuildingBlock.
require 'facets/buildable' require 'xmlmarkup' # hypothetical library module XMLMarkup include Buildable alias :build :element end doc = XMLMarkup.build do html do head do title "Test" end body do i "Hello" br text "Test" text "Hey" end end end
produces
<html><head><title>Test</title><body><i>Hello</i><br />TestHey</body></html>
This is based on BuildingBlock. Refer to it for more information.
Methods
included
Public Class methods
[ + ]
# File lib/more/facets/buildable.rb, line 144 def self.included(base) singleton = (class << base; self; end) singleton.send(:define_method, :builder) do @builder ||= BuildingBlock.new(base, :build) end base.module_eval %{ def self.build(&block) builder.instance_eval(&block) end } end