Class: Vident::Internals::Declarations
- Inherits:
-
Object
- Object
- Vident::Internals::Declarations
- Defined in:
- lib/vident/internals/declarations.rb
Overview
Frozen per-class aggregate of raw ‘Declaration` entries from `stimulus do` blocks. Keyed kinds use `[key, Declaration]` pairs so later same-key entries replace earlier ones; positional kinds are flat arrays where later blocks append.
Constant Summary collapse
- EMPTY_ARRAY =
[].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.empty ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vident/internals/declarations.rb', line 22 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
33 34 35 36 37 |
# File 'lib/vident/internals/declarations.rb', line 33 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
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vident/internals/declarations.rb', line 39 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 |