Class: ViewComponent::Storybook::MethodArgs::DryInitializerComponentConstructorArgs::DryConstructorParametersNames
- Inherits:
-
MethodParametersNames
- Object
- MethodParametersNames
- ViewComponent::Storybook::MethodArgs::DryInitializerComponentConstructorArgs::DryConstructorParametersNames
- Defined in:
- lib/view_component/storybook/method_args/dry_initializer_component_constructor_args.rb
Overview
Method Parameters names that are dry-initialize aware THe main difference is that Dry Initializer keyword args cannot be deduced from the constructor initialize params Instead we have to introspect the dry_initializer config for the option definitions
Constant Summary
Constants inherited from MethodParametersNames
MethodParametersNames::ARG_TYPES, MethodParametersNames::KWARG_REST, MethodParametersNames::KWARG_TYPES, MethodParametersNames::REQ_ARG_TYPE, MethodParametersNames::REQ_KWARG_TYPE, MethodParametersNames::REST
Instance Attribute Summary collapse
-
#dry_initializer ⇒ Object
readonly
Returns the value of attribute dry_initializer.
Attributes inherited from MethodParametersNames
Instance Method Summary collapse
-
#initialize(component_class) ⇒ DryConstructorParametersNames
constructor
A new instance of DryConstructorParametersNames.
-
#req_kwarg_names ⇒ Object
Required keywords are the only thing we need.
Methods inherited from MethodParametersNames
#arg_name, #covers_required_kwargs?, #include_kwarg?, #max_arg_count, #min_arg_count
Constructor Details
#initialize(component_class) ⇒ DryConstructorParametersNames
Returns a new instance of DryConstructorParametersNames.
18 19 20 21 |
# File 'lib/view_component/storybook/method_args/dry_initializer_component_constructor_args.rb', line 18 def initialize(component_class) super(component_class.instance_method(INITIALIZE_METHOD)) @dry_initializer = component_class.dry_initializer end |
Instance Attribute Details
#dry_initializer ⇒ Object (readonly)
Returns the value of attribute dry_initializer.
16 17 18 |
# File 'lib/view_component/storybook/method_args/dry_initializer_component_constructor_args.rb', line 16 def dry_initializer @dry_initializer end |
Instance Method Details
#req_kwarg_names ⇒ Object
Required keywords are the only thing we need. We could define kwarg_names similarly but wihout the ‘optional` check. However, dry-initializer always ends has supports_keyrest? == true so kwarg_names isn’t needed
26 27 28 29 30 |
# File 'lib/view_component/storybook/method_args/dry_initializer_component_constructor_args.rb', line 26 def req_kwarg_names @req_kwarg_names ||= dry_initializer.definitions.map do |name, definition| name if definition.option && !definition.optional end.compact end |