Class: Lustr::Gadget

Inherits:
BlankSlate show all
Includes:
WidgetBase
Defined in:
lib/lustr/gadget.rb

Instance Attribute Summary collapse

Attributes included from WidgetBase

#eval_context, #gadget, #label, #name, #options, #parent

Instance Method Summary collapse

Methods included from WidgetBase

#<<, #_add, #children, #init_options, #option, #raise_event, #to_s

Constructor Details

#initialize(builder, parent_widget = nil, ctlr = NullController, options = {}) ⇒ Gadget

Returns a new instance of Gadget.



25
26
27
28
29
30
# File 'lib/lustr/gadget.rb', line 25

def initialize(builder, parent_widget=nil, ctlr=NullController, options={})
	@builder=builder
	@widgets={}
	@parent_widget=parent_widget
	self.controller=ctlr
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



67
68
69
70
71
72
# File 'lib/lustr/gadget.rb', line 67

def method_missing(sym, *args)
	result=widgets[sym.to_s]

	return result if result
	return super
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



22
23
24
# File 'lib/lustr/gadget.rb', line 22

def builder
  @builder
end

#controllerObject

Returns the value of attribute controller.



23
24
25
# File 'lib/lustr/gadget.rb', line 23

def controller
  @controller
end

#parent_widgetObject (readonly)

Returns the value of attribute parent_widget.



22
23
24
# File 'lib/lustr/gadget.rb', line 22

def parent_widget
  @parent_widget
end

#widgetsObject (readonly)

Returns the value of attribute widgets.



22
23
24
# File 'lib/lustr/gadget.rb', line 22

def widgets
  @widgets
end

Instance Method Details

#contents(ctxt) ⇒ Object



63
64
65
# File 'lib/lustr/gadget.rb', line 63

def contents(ctxt)
	ctxt.build_gadget_ref(self)
end

#generate(ctxt) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/lustr/gadget.rb', line 53

def generate(ctxt)
	if parent_widget
		contents(ctxt)
	else
		children.each do |child|
			child.generate(ctxt)
		end
	end
end

#resolveObject



38
39
40
41
# File 'lib/lustr/gadget.rb', line 38

def resolve
	return children[0].resolve if children.size>0
	return super
end

#resolve_parentObject



43
44
45
# File 'lib/lustr/gadget.rb', line 43

def resolve_parent
	return parent_widget
end

#showObject



47
48
49
50
51
# File 'lib/lustr/gadget.rb', line 47

def show
	children.each do |child|
		child.show
	end
end