Created
September 8, 2021 12:12
-
-
Save rx/dc9cc7a72e81ec5ae115482331514072 to your computer and use it in GitHub Desktop.
Service Validation Example
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
module Services | |
class DoesSomething < BaseService | |
def initialize(model_ids:) | |
@model_ids = model_ids | |
validate_params | |
end | |
def call | |
# Your service logic goes here | |
success | |
end | |
alias perform call | |
private | |
def validate_params | |
if @model_ids.empty | |
raise ::Errors::ParameterValidation, 'No model ids provides. You must pass at least one model id.' | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment