Class: Vident2::Internals::Draft Private
- Inherits:
-
Object
- Object
- Vident2::Internals::Draft
- Defined in:
- lib/vident2/internals/draft.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.
Per-instance mutable working copy. Seven Arrays, one per Registry kind. ‘add_<kind>(value_or_values)` mutators are the single sanctioned seam for cross-instance mutation (outlet-host pattern) and for `add_stimulus_*` calls from `after_component_initialize`.
After ‘seal!` the Draft is closed — any further `add_*` raises `Vident2::StateError`. The sealed Plan is a frozen Data.define snapshot.
Instance Method Summary collapse
-
#initialize(**collections) ⇒ Draft
constructor
private
A new instance of Draft.
- #plan ⇒ Object private
-
#seal! ⇒ Object
private
Freeze the working copy and snapshot as a frozen Plan.
- #sealed? ⇒ Boolean private
Constructor Details
#initialize(**collections) ⇒ Draft
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 a new instance of Draft.
17 18 19 20 21 |
# File 'lib/vident2/internals/draft.rb', line 17 def initialize(**collections) @collections = Registry.names.to_h { |name| [name, []] } collections.each { |k, v| @collections[k] = v.dup if @collections.key?(k) } @sealed = false end |
Instance Method Details
#plan ⇒ 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.
49 |
# File 'lib/vident2/internals/draft.rb', line 49 def plan = seal! |
#seal! ⇒ 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.
Freeze the working copy and snapshot as a frozen Plan. Idempotent: subsequent calls return the memoised Plan.
41 42 43 44 45 46 47 |
# File 'lib/vident2/internals/draft.rb', line 41 def seal! return @plan if @sealed @sealed = true @collections.each_value(&:freeze) @collections.freeze @plan = Plan.new(**@collections) end |
#sealed? ⇒ 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.
37 |
# File 'lib/vident2/internals/draft.rb', line 37 def sealed? = @sealed |