diff --git a/README.md b/README.md index 277f3a5..71c39f1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ class CreateUser < SorbetOperation::Base @user_params = user_params end - protected + private sig { returns(ValueType) } def execute @@ -71,7 +71,7 @@ An operation is a Ruby class that derives from `SorbetOperation::Base`. `SorbetO 1. define the return type using the `ValueType` generic type member 2. define an `#execute` method that returns a `ValueType` -The `#execute` method should be `protected` or `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.) +The `#execute` method should be `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.) The `#execute` method does not take any arguments. Most operations require one or more input values. Input values should be passed to the `#initialize` constructor method and stored as instance variables, which can then be accessed from the `#execute` body. diff --git a/lib/sorbet_operation/base.rb b/lib/sorbet_operation/base.rb index c7ff67e..afc48f8 100644 --- a/lib/sorbet_operation/base.rb +++ b/lib/sorbet_operation/base.rb @@ -57,7 +57,7 @@ def perform sig { params(logger: ::Logger).void } attr_writer :logger - protected + private # Implement this method in subclasses to perform the operation. # @@ -70,7 +70,7 @@ def perform # exception. The exception will not be caught and will be propagated to # the caller. # - # This method should be declared as `protected` in subclasses to prevent + # This method should be declared as `private` in subclasses to prevent # callers from calling it directly. Callers should instead call {#perform} # to perform the operation and get the result. sig { abstract.returns(ValueType) } diff --git a/test/sorbet_operation/base_test.rb b/test/sorbet_operation/base_test.rb index 2a26e49..e5d3352 100644 --- a/test/sorbet_operation/base_test.rb +++ b/test/sorbet_operation/base_test.rb @@ -19,7 +19,7 @@ def initialize(dividend, divisor) @divisor = divisor end - protected + private sig { override.returns(Float) } def execute