Module: Plushie::UI::Context Private

Defined in:
lib/plushie/ui.rb,
sig/plushie/ui.rbs

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Thread-local context for nesting DSL calls.

Class Method Summary collapse

Class Method Details

.clearnil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Clear the context stack.

Returns:

  • (nil)


57
58
59
# File 'lib/plushie/ui.rb', line 57

def self.clear
  Thread.current[:_plushie_ctx_stack] = nil
end

.currentArray[Node]?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the current context.

Returns:

  • (Array[Node], nil)


42
# File 'lib/plushie/ui.rb', line 42

def self.current = (Thread.current[:_plushie_ctx_stack] || []).last

.popArray[Node]?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pop the top context.

Returns:

  • (Array[Node], nil)


50
51
52
53
# File 'lib/plushie/ui.rb', line 50

def self.pop
  stack = Thread.current[:_plushie_ctx_stack]
  stack&.pop
end

.push(children) ⇒ Array[Array[Node]]

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Push a new context.

Parameters:

  • children (Array[Node])

Returns:

  • (Array[Array[Node]])


46
# File 'lib/plushie/ui.rb', line 46

def self.push(children) = (Thread.current[:_plushie_ctx_stack] ||= []).push(children)