Skip to content

Commit

Permalink
Merge pull request #9 from thatch-health/protected-private
Browse files Browse the repository at this point in the history
Change protected visibility to private
  • Loading branch information
bdewater-thatch authored May 30, 2024
2 parents b009a7b + e6ae0df commit a729e97
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.6
3.3.1
8 changes: 5 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ GEM
regexp_parser (2.9.0)
reline (0.4.2)
io-console (~> 0.5)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down Expand Up @@ -95,6 +96,7 @@ GEM
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
stringio (3.1.0)
strscan (3.1.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tapioca (0.12.0)
Expand All @@ -108,7 +110,7 @@ GEM
yard-sorbet
thor (1.3.0)
unicode-display_width (2.5.0)
yard (0.9.34)
yard (0.9.36)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
Expand Down Expand Up @@ -139,4 +141,4 @@ DEPENDENCIES
yard-sorbet

BUNDLED WITH
2.5.5
2.5.9
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CreateUser < SorbetOperation::Base
@user_params = user_params
end

protected
private

sig { returns(ValueType) }
def execute
Expand Down Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions lib/sorbet_operation/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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) }
Expand Down
Loading

0 comments on commit a729e97

Please sign in to comment.