Skip to content

Instantly share code, notes, and snippets.

@romkaspb
Last active September 27, 2017 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romkaspb/807c3bf92d1894c0b9270f93997b21a2 to your computer and use it in GitHub Desktop.
Save romkaspb/807c3bf92d1894c0b9270f93997b21a2 to your computer and use it in GitHub Desktop.
registration_service.rb
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