Sha256: e12134de88f1ee1b76a85babce4b20ea8b9557516ed4e7ef6fecc07a6d76420c
Contents?: true
Size: 1014 Bytes
Versions: 10
Compression:
Stored size: 1014 Bytes
Contents
module Glue # A Builder integrates a number of Modules containing text # manipulation utilities and provides an alternative # 'accomulation' interface. class Builder # The builder output is accomulated in the buffer. attr_accessor :buffer class << self def include_builder(*modules) for mod in modules include mod for meth in mod.public_instance_methods self.module_eval %{ alias_method :_mixin_#{meth}, :#{meth} def #{meth}(*args) @buffer << _mixin_#{meth}(*args) return self end } end end end alias_method :builder, :include_builder end # Provide the target where the builder output will be # accomulated. The builder utilizes duck typing to make it # compatible with anly target responding to <<. def initialize(buffer = '', *modules) @buffer = buffer end end end # * George Moschovitis <gm@navel.gr> __END__
Version data entries
10 entries across 10 versions & 1 rubygems