Class: ViewComponent::Storybook::MethodArgs::ComponentConstructorArgs

Inherits:
ControlMethodArgs show all
Defined in:
lib/view_component/storybook/method_args/component_constructor_args.rb

Overview

Class representing the constructor args for a Component

Instance Attribute Summary

Attributes inherited from ControlMethodArgs

#param_prefix

Attributes inherited from MethodArgs

#args, #kwargs, #target_method, #target_method_params_names

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ControlMethodArgs

#call, #controls, #resolve_method_args, #with_param_prefix

Constructor Details

#initialize(component_class, *args, **kwargs) ⇒ ComponentConstructorArgs

Returns a new instance of ComponentConstructorArgs.



17
18
19
# File 'lib/view_component/storybook/method_args/component_constructor_args.rb', line 17

def initialize(component_class, *args, **kwargs)
  super(component_class.instance_method(:initialize), *args, **kwargs)
end

Class Method Details

.from_component_class(component_class, *args, **kwargs) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/view_component/storybook/method_args/component_constructor_args.rb', line 9

def self.from_component_class(component_class, *args, **kwargs)
  if DryInitializerComponentConstructorArgs.dry_initialize?(component_class)
    DryInitializerComponentConstructorArgs.new(component_class, *args, **kwargs)
  else
    new(component_class, *args, **kwargs)
  end
end