Class: Teek::UI::Scope
- Inherits:
-
Object
- Object
- Teek::UI::Scope
- Defined in:
- lib/teek/ui/scope.rb
Overview
A component's build-time namespace - ambient builder state, kept on
a stack parallel to WidgetDSL's own @stack (see
WidgetDSL#component). A real object rather than a bare String/nil
on purpose: TOP_LEVEL is one unmistakable sentinel, checked by
identity (+#top_level?+/+#equal?+) rather than a value any caller
could accidentally collide with (+nil+, an empty string, a label
someone else also chose, ...). Two Scope instances are never the
same scope just because they share a label - Document keys on
identity, so every WidgetDSL#component call gets a genuinely
fresh, distinct scope regardless of what label (if any) it's given.
Constant Summary collapse
- TOP_LEVEL =
The single sentinel for "not inside any component" - the default scope for a build that never calls WidgetDSL#component at all.
Scope.new(:top_level).freeze
Instance Attribute Summary collapse
-
#label ⇒ Symbol, ...
readonly
A human-readable label, for error messages/debugging - never part of identity/equality.
-
#parent ⇒ Scope?
readonly
The enclosing scope this one was opened inside -
nilonly for TOP_LEVEL itself.
Instance Method Summary collapse
-
#initialize(label = nil, parent: nil) ⇒ Scope
constructor
private
A new instance of Scope.
-
#top_level? ⇒ Boolean
Whether this is TOP_LEVEL.
Constructor Details
#initialize(label = nil, parent: nil) ⇒ Scope
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.
Returns a new instance of Scope.
25 26 27 28 |
# File 'lib/teek/ui/scope.rb', line 25 def initialize(label = nil, parent: nil) @label = label @parent = parent end |
Instance Attribute Details
#label ⇒ Symbol, ... (readonly)
Returns a human-readable label, for error messages/debugging - never part of identity/equality.
18 19 20 |
# File 'lib/teek/ui/scope.rb', line 18 def label @label end |