Module: Phlex::Sorbet::InstanceMethods

Extended by:
T::Sig
Defined in:
lib/phlex/sorbet/instance_methods.rb

Overview

Instance methods prepended into components that include Phlex::Sorbet. Wraps ‘initialize` to build a typed Props struct from incoming kwargs and exposes it via the `props` accessor.

Instance Method Summary collapse

Instance Method Details

#initialize(**kwargs) ⇒ Object

Builds typed props, then calls super so the Phlex base class can initialize as usual.

Parameters:

  • kwargs (Hash)

    Arguments matching the Props T::Struct

Raises:



19
20
21
22
# File 'lib/phlex/sorbet/instance_methods.rb', line 19

def initialize(**kwargs, &)
  @props = self.class.build_props(**kwargs)
  super(&)
end

#propsObject



28
29
30
# File 'lib/phlex/sorbet/instance_methods.rb', line 28

def props
  @props
end