-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fallback): introduce fall_result that is called for both failure…
… and error, but haas lower priority when specific method is defined
- Loading branch information
Showing
22 changed files
with
868 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ def result | |
success | ||
end | ||
|
||
def fallback_failure_result | ||
def fallback_result | ||
success | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ def result | |
success | ||
end | ||
|
||
def fallback_failure_result | ||
def fallback_result | ||
success | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ def result | |
success | ||
end | ||
|
||
def fallback_failure_result | ||
def fallback_result | ||
success | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...enient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "can_have_fallbacks/concern" | ||
require_relative "can_have_fallbacks/exceptions" | ||
require_relative "can_have_fallbacks/middleware" |
31 changes: 31 additions & 0 deletions
31
...ice/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/exceptions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConvenientService | ||
module Service | ||
module Plugins | ||
module CanHaveSteps | ||
module Entities | ||
class Step | ||
module Plugins | ||
module CanHaveFallbacks | ||
module Exceptions | ||
class FallbackResultIsNotOverridden < ::ConvenientService::Exception | ||
def initialize_with_kwargs(step:, service:, status:) | ||
message = <<~TEXT | ||
Neither `fallback_#{status}_result` nor `fallback_result` methods of `#{service.class}` are overridden, but the step is marked to be fallbacked. | ||
Either override one of those methods or remove the `fallback` option from the corresponding step definition in `#{step.container.klass}`. | ||
TEXT | ||
|
||
initialize(message) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConvenientService | ||
module Utils | ||
module String | ||
class Enclose < Support::Command | ||
## | ||
# @!attribute [r] string | ||
# @return [String] | ||
# | ||
attr_reader :string | ||
|
||
## | ||
# @!attribute [r] char | ||
# @return [String] | ||
# | ||
attr_reader :char | ||
|
||
## | ||
# @param string [#to_s] | ||
# @param char [String] | ||
# @return [void] | ||
# | ||
def initialize(string, char) | ||
@string = string | ||
@char = char | ||
end | ||
|
||
## | ||
# @return [String] | ||
# | ||
def call | ||
return char unless string | ||
|
||
"#{char}#{string}#{char}" | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.