Class: Vident::Stimulus::Primitive
- Inherits:
-
Object
- Object
- Vident::Stimulus::Primitive
show all
- Defined in:
- lib/vident/stimulus/primitive.rb
Overview
A Stimulus primitive kind: name, plus the Value/Collection classes that back it. Two concrete subclasses distinguish how the primitive behaves when a Hash is passed to the plural parser:
- `Keyed` — `{a: 1, b: 2}` expands to one value object per pair.
Used for values / params / classes / outlets.
- `Positional` — `{...}` is a single-arg descriptor (e.g. Action's
`{event:, method:, ...}` short form).
Used for controllers / actions / targets.
Instance Method Summary
collapse
Instance Method Details
#key ⇒ Object
The primitive’s key in Vident’s attribute namespace. Used both as the parser method name (‘def stimulus_values(…)`) and as the hash key in DSL attrs / component props / `root_element_attributes` — the same Symbol serves all three roles.
24
|
# File 'lib/vident/stimulus/primitive.rb', line 24
def key = :"stimulus_#{name}"
|
#keyed? ⇒ Boolean
27
|
# File 'lib/vident/stimulus/primitive.rb', line 27
def keyed? = raise NotImplementedError
|
#singular ⇒ Object
18
|
# File 'lib/vident/stimulus/primitive.rb', line 18
def singular = name.to_s.singularize.to_sym
|
#singular_key ⇒ Object
25
|
# File 'lib/vident/stimulus/primitive.rb', line 25
def singular_key = :"stimulus_#{singular}"
|