Class: Vident2::Internals::Declarations Private
- Inherits:
-
Data
- Object
- Data
- Vident2::Internals::Declarations
- Defined in:
- lib/vident2/internals/declarations.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Frozen per-class aggregate of what ‘stimulus do … end` declared. One field per kind (plural Registry name) plus `values_from_props`. Entries stay as raw `Declaration` records — the Resolver parses them into `Stimulus::*` value objects at instance init, not here.
Keyed kinds (values, params, class_maps, outlets) use ‘(key, entry)` pairs to let a later block’s same-key entry replace an earlier one. Positional kinds (controllers, actions, targets) are flat arrays; later blocks append.
Constant Summary collapse
- EMPTY_ARRAY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[].freeze
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#class_maps ⇒ Object
readonly
Returns the value of attribute class_maps.
-
#controllers ⇒ Object
readonly
Returns the value of attribute controllers.
-
#outlets ⇒ Object
readonly
Returns the value of attribute outlets.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#values_from_props ⇒ Object
readonly
Returns the value of attribute values_from_props.
Class Method Summary collapse
- .empty ⇒ Object private
Instance Method Summary collapse
- #any? ⇒ Boolean private
-
#merge(other) ⇒ Object
private
Merge two Declarations, treating ‘self` as parent and `other` as child.
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def actions @actions end |
#class_maps ⇒ Object (readonly)
Returns the value of attribute class_maps
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def class_maps @class_maps end |
#controllers ⇒ Object (readonly)
Returns the value of attribute controllers
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def controllers @controllers end |
#outlets ⇒ Object (readonly)
Returns the value of attribute outlets
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def outlets @outlets end |
#params ⇒ Object (readonly)
Returns the value of attribute params
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def params @params end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def targets @targets end |
#values ⇒ Object (readonly)
Returns the value of attribute values
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def values @values end |
#values_from_props ⇒ Object (readonly)
Returns the value of attribute values_from_props
17 18 19 |
# File 'lib/vident2/internals/declarations.rb', line 17 def values_from_props @values_from_props end |
Class Method Details
.empty ⇒ Object
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.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vident2/internals/declarations.rb', line 29 def self.empty = @empty ||= new( controllers: EMPTY_ARRAY, actions: EMPTY_ARRAY, targets: EMPTY_ARRAY, outlets: EMPTY_ARRAY, values: EMPTY_ARRAY, params: EMPTY_ARRAY, class_maps: EMPTY_ARRAY, values_from_props: EMPTY_ARRAY ).freeze |
Instance Method Details
#any? ⇒ Boolean
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.
40 41 42 43 44 |
# File 'lib/vident2/internals/declarations.rb', line 40 def any? !controllers.empty? || !actions.empty? || !targets.empty? || !outlets.empty? || !values.empty? || !params.empty? || !class_maps.empty? || !values_from_props.empty? end |
#merge(other) ⇒ Object
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.
Merge two Declarations, treating ‘self` as parent and `other` as child. Positional kinds concat (parent first, then child). Keyed kinds last-wins on matching key.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vident2/internals/declarations.rb', line 49 def merge(other) self.class.new( controllers: concat_positional(controllers, other.controllers), actions: concat_positional(actions, other.actions), targets: concat_positional(targets, other.targets), outlets: merge_keyed(outlets, other.outlets), values: merge_keyed(values, other.values), params: merge_keyed(params, other.params), class_maps: merge_keyed(class_maps, other.class_maps), values_from_props: (values_from_props + other.values_from_props).uniq.freeze ) end |