mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 21:22:33 +00:00
dry up DSL's flow/stack methods
This commit is contained in:
@@ -1,27 +1,11 @@
|
|||||||
module CyberarmEngine
|
module CyberarmEngine
|
||||||
module DSL
|
module DSL
|
||||||
def flow(options = {}, &block)
|
def flow(options = {}, &block)
|
||||||
options[:parent] = @containers.last
|
container(CyberarmEngine::Element::Flow, options, &block)
|
||||||
options[:theme] = current_theme
|
|
||||||
_container = Element::Flow.new(options, block)
|
|
||||||
@containers << _container
|
|
||||||
_container.build
|
|
||||||
_container.parent.add(_container)
|
|
||||||
@containers.pop
|
|
||||||
|
|
||||||
return _container
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stack(options = {}, &block)
|
def stack(options = {}, &block)
|
||||||
options[:parent] = @containers.last
|
container(CyberarmEngine::Element::Stack, options, &block)
|
||||||
options[:theme] = current_theme
|
|
||||||
_container = Element::Stack.new(options, block)
|
|
||||||
@containers << _container
|
|
||||||
_container.build
|
|
||||||
_container.parent.add(_container)
|
|
||||||
@containers.pop
|
|
||||||
|
|
||||||
return _container
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def label(text, options = {}, &block)
|
def label(text, options = {}, &block)
|
||||||
@@ -94,5 +78,19 @@ module CyberarmEngine
|
|||||||
private def element_parent
|
private def element_parent
|
||||||
self.is_a?(CyberarmEngine::Element::Container) ? self : @containers.last
|
self.is_a?(CyberarmEngine::Element::Container) ? self : @containers.last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def container(klass, options = {}, &block)
|
||||||
|
options[:parent] = element_parent
|
||||||
|
options[:theme] = current_theme
|
||||||
|
|
||||||
|
_container = klass.new(options, block)
|
||||||
|
|
||||||
|
@containers << _container
|
||||||
|
_container.build
|
||||||
|
_container.parent.add(_container)
|
||||||
|
@containers.pop
|
||||||
|
|
||||||
|
return _container
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user