Class: Lustr::SimpleBuilder

Inherits:
BuilderBase show all
Defined in:
lib/lustr/builder.rb

Overview

SimpleBuilder handles the really simple case where a builder simply instantiates some widget class. Then, rather than having to create custom builder subclasses for each widget class, you can simply Lustr.declare() an instance of SimpleBuilder with the appropriate widget class as a parameter.

Instance Attribute Summary

Attributes inherited from BuilderBase

#children, #event_handlers, #name, #options, #widget_type

Instance Method Summary collapse

Methods inherited from BuilderBase

#<<, #all_event_handlers, #build_all

Constructor Details

#initialize(widget_type, klass, options = {}) ⇒ SimpleBuilder

Returns a new instance of SimpleBuilder.



103
104
105
106
# File 'lib/lustr/builder.rb', line 103

def initialize(widget_type, klass, options={})
			super(widget_type, options)
			@widget_class=klass
end

Instance Method Details

#build(parent_widget) ⇒ Object



112
113
114
# File 'lib/lustr/builder.rb', line 112

def build(parent_widget)
	@widget_class.new
end

#dup_from(options) ⇒ Object



108
109
110
# File 'lib/lustr/builder.rb', line 108

def dup_from(options)
	self.class.new(widget_type, @widget_class, options)
end