Class: Mayu::VDOM::ComponentMarshaler

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mayu/vdom/component_marshaler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ ComponentMarshaler



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mayu/vdom/component_marshaler.rb', line 14

def initialize(type)
  @type =
    T.let(
      if Component === type
        klass = T.cast(type, T.class_of(Component::Base))

        # TODO: Would be better to do something like
        # resources.resouce_for_type(klass)
        if resource =
             (
               begin
                 klass.__mayu_resource
               rescue StandardError
                 nil
               end
             )
          component = resource.path
          { component: }
        else
          { klass: klass }
        end
      else
        type
      end,
      T.untyped
    )
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/mayu/vdom/component_marshaler.rb', line 11

def type
  @type
end

Instance Method Details

#marshal_dumpObject



43
44
45
# File 'lib/mayu/vdom/component_marshaler.rb', line 43

def marshal_dump
  @type
end

#marshal_load(a) ⇒ Object



48
49
50
# File 'lib/mayu/vdom/component_marshaler.rb', line 48

def marshal_load(a)
  @type = a
end