Class: ViewComponentReducible::State::Envelope

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component_reducible/state/envelope.rb

Overview

Envelope builder for initial state payloads.

Class Method Summary collapse

Class Method Details

.initial(root_component_klass, path: 'root') ⇒ Hash{String=>Object}

Build an initial envelope for a component.

Parameters:

  • (defaults to: 'root')

Returns:



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/view_component_reducible/state/envelope.rb', line 11

def self.initial(root_component_klass, path: 'root')
  schema = root_component_klass.vcr_state_schema
  data = schema.defaults
  {
    'v' => 1,
    'root' => root_component_klass.vcr_id,
    'path' => path,
    'data' => data,
    'children' => {}
  }
end