Class: Lilac::Directives::Value
- Inherits:
-
Object
- Object
- Lilac::Directives::Value
- Defined in:
- lib/lilac/directives/value.rb
Overview
The right-hand side of a directive that takes a reactive value. Two kinds exist, both single-identifier (no dot / no path / no expression):
- `@ivar` — a host Signal/Computed. Resolves via
`Evaluator#lookup_ivar` and feeds into
`bind ref, prop: signal` directly.
- bare ident — a field of the current iteration item.
`Evaluator#read` reads `item[name]` (Hash key
first, then String fallback, then public_send).
Only meaningful inside a `data-each` body;
value-binding dispatch silent-skips when
`item.nil?` (= scanning the host root).
Duplicate pair (build-time / runtime). See decisions §17.
Value.parse returns Ivar, BareIdent, or nil for invalid
input — callers raise their own error with directive context.
Match precedence: @ivar first (unambiguous prefix), then bare
ident (everything else that looks like a Ruby identifier).
Defined Under Namespace
Constant Summary collapse
- IVAR =
Anchors use
^/$not\A/\z— see Grammar for the mruby-regexp-compat compatibility note. /^@[a-zA-Z_]\w*\??$/- BARE_IDENT =
/^[a-zA-Z_]\w*\??$/
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #bare_ident? ⇒ Boolean
-
#initialize(raw) ⇒ Value
constructor
A new instance of Value.
- #inspect ⇒ Object
- #ivar? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(raw) ⇒ Value
Returns a new instance of Value.
40 41 42 |
# File 'lib/lilac/directives/value.rb', line 40 def initialize(raw) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
38 39 40 |
# File 'lib/lilac/directives/value.rb', line 38 def raw @raw end |
Class Method Details
Instance Method Details
#bare_ident? ⇒ Boolean
56 57 58 |
# File 'lib/lilac/directives/value.rb', line 56 def false end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/lilac/directives/value.rb', line 48 def inspect @raw.inspect end |
#ivar? ⇒ Boolean
52 53 54 |
# File 'lib/lilac/directives/value.rb', line 52 def ivar? false end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/lilac/directives/value.rb', line 44 def to_s @raw end |