Class: Vident2::Internals::Declarations Private

Inherits:
Data
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions

Returns:

  • (Object)

    the current value of actions



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def actions
  @actions
end

#class_mapsObject (readonly)

Returns the value of attribute class_maps

Returns:

  • (Object)

    the current value of class_maps



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def class_maps
  @class_maps
end

#controllersObject (readonly)

Returns the value of attribute controllers

Returns:

  • (Object)

    the current value of controllers



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def controllers
  @controllers
end

#outletsObject (readonly)

Returns the value of attribute outlets

Returns:

  • (Object)

    the current value of outlets



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def outlets
  @outlets
end

#paramsObject (readonly)

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def params
  @params
end

#targetsObject (readonly)

Returns the value of attribute targets

Returns:

  • (Object)

    the current value of targets



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def targets
  @targets
end

#valuesObject (readonly)

Returns the value of attribute values

Returns:

  • (Object)

    the current value of values



17
18
19
# File 'lib/vident2/internals/declarations.rb', line 17

def values
  @values
end

#values_from_propsObject (readonly)

Returns the value of attribute values_from_props

Returns:

  • (Object)

    the current value of 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

.emptyObject

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.

Returns:

  • (Boolean)


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