Last active
September 27, 2017 10:39
-
-
Save rndev15/807c3bf92d1894c0b9270f93997b21a2 to your computer and use it in GitHub Desktop.
registration_service.rb
This file contains hidden or 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
class RegistrationService < ServiceFactory | |
def self.call(params) | |
@@errors = [] | |
@params = params | |
@user = User.new( @params ) | |
if @user.save | |
@user | |
else | |
@@errors << @user.errors | |
end | |
self | |
end | |
def self.valid? | |
@@errors.empty? | |
end | |
def self.errors | |
@@errors | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment