Class: Vident::Internals::Draft

Inherits:
Object
  • Object
show all
Defined in:
lib/vident/internals/draft.rb

Overview

Per-instance mutable accumulator; seals into a frozen Plan once rendering begins.

Instance Method Summary collapse

Constructor Details

#initialize(**collections) ⇒ Draft

Returns a new instance of Draft.



10
11
12
13
14
# File 'lib/vident/internals/draft.rb', line 10

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

#planObject



36
# File 'lib/vident/internals/draft.rb', line 36

def plan = seal!

#seal!Object



28
29
30
31
32
33
34
# File 'lib/vident/internals/draft.rb', line 28

def seal!
  return @plan if @sealed
  @sealed = true
  @collections.each_value(&:freeze)
  @collections.freeze
  @plan = Plan.new(**@collections)
end

#sealed?Boolean

Returns:

  • (Boolean)


26
# File 'lib/vident/internals/draft.rb', line 26

def sealed? = @sealed