What is a step alias input?
A step alias input renames a step's parameter to a different organizer instance method, using a one-key hash in
in::{step_parameter_name: :organizer_method_name}.class CalculateDoubled include ConvenientService::Standard::Config attr_reader :number def initialize(number:) @number = number end def result success(doubled: number * 2) end end class AwardLoyaltyPoints include ConvenientService::Standard::Config step CalculateDoubled, in: {number: :count}, out: {doubled: :points} private def count 21 end end result = AwardLoyaltyPoints.result result.success? # => true result.data[:points] # => 42in: {number: :count}callscounton the organizer (AwardLoyaltyPoints) and passes its return value asnumber:to the step (CalculateDoubled).As a rule of thumb, the organizer method name is always on the right side of the hash, the step's parameter name is always on the left.
Use a step alias input when the organizer has no method matching the step's parameter name, or when the matching organizer method already serves another purpose. Here the step needs
number:, but the organizer's method is namedcount.Like a usual step input, the aliased organizer method can be
private-countisprivateabove.
See also
- What step input types are available?
- What is a usual step input?
- What is a step raw input?
- What is a step proc input?
- What is a step?