module Dill::Widgets::DSL
Public Instance Methods
form(name, *rest, &block)
click to toggle source
Declares a new form widget.
See features/role.feature.
# File lib/dill/widgets/dsl.rb, line 7 def form(name, *rest, &block) widget name, *rest, Dill::Form, &block end
list(name, *rest, &block)
click to toggle source
Declares a new list widget.
See features/roles/list.feature.
# File lib/dill/widgets/dsl.rb, line 14 def list(name, *rest, &block) widget name, *rest, Dill::List, &block end
widget(name, selector_or_parent, parent = Widget, &block)
click to toggle source
Declares a new child widget.
See github.com/mojotech/dill/blob/master/features/roles/widget.feature
# File lib/dill/widgets/dsl.rb, line 21 def widget(name, selector_or_parent, parent = Widget, &block) raise ArgumentError, "`#{name}' is a reserved name" \ if WidgetParts::Container.instance_methods.include?(name.to_sym) case selector_or_parent when String, Array, Proc selector, type = selector_or_parent, parent when Class selector, type = selector_or_parent.selector, selector_or_parent else raise ArgumentError, "wrong number of arguments (#{rest.size} for 1)" end raise TypeError, "can't convert `#{type}' to Widget" \ unless type.methods.include?(:selector) raise ArgumentError, "missing selector" unless selector || type.selector child = WidgetClass.new(selector, type, &block) const_set(Dill::WidgetName.new(name).to_sym, child) child end