Use upper camel case for method steps
Name a method step's method in upper camel case (e.g.
AssertValidAmount), not the snake_case used for regular Ruby methods.This makes it visually obvious, at a glance, which private methods are steps versus ordinary helpers.
class ParseAmount include ConvenientService::Standard::Config attr_reader :raw_amount step :AssertValidAmount, in: :raw_amount step :result, in: :raw_amount, out: :cents def initialize(raw_amount:) @raw_amount = raw_amount end def result success(cents: to_cents) end private def AssertValidAmount return failure("Amount `#{raw_amount}` is not a valid positive number") unless raw_amount.to_s.match?(/\A\d+(\.\d{1,2})?\z/) success end def to_cents (raw_amount.to_f * 100).round end endAssertValidAmountis a method step (upper camel case, declared viastep :AssertValidAmountabove).to_centsis a regular private helper (snake_case, called directly fromresult). Just by looking at a method's name, you know which one it is.
See also
- What is a step?
- What is a method step?
- What is a service step?
- Declare
in:/out:explicitly on method steps