Sha256: cdb5c8f5c5e6fc715fc977f8ded2d0450640b3e211fcc101d894fe9089182c71
Contents?: true
Size: 1.34 KB
Versions: 14
Compression:
Stored size: 1.34 KB
Contents
module Cmor module UserArea class CreateDefaultUserService < ::Cmor::UserArea::ApplicationService class Result < ::Cmor::UserArea::ApplicationService::Result attr_accessor :user, :email, :password, :password_confirmation, :active, :approved, :confirmed end attr_accessor :email, :password, :password_confirmation, :active, :approved, :confirmed def _perform @result.user = create_user end private def create_user user = Cmor::UserArea::User.new(user_attributes) say "Creating user [#{user.email}]" do if user.save say '=> [OK]' else add_error_and_say(:base, "=> [FAILED] Errors: #{user.errors.full_messages.to_sentence}") end user end end def user_attributes user_attribute_defaults.merge(user_attribute_overrides) end def user_attribute_overrides { email: email, password: password, password_confirmation: password_confirmation, active: active, approved: approved, confirmed: confirmed }.compact end def user_attribute_defaults { email: 'user@example.com', password: 'password', password_confirmation: 'password', active: true, approved: true, confirmed: true } end end end end
Version data entries
14 entries across 14 versions & 1 rubygems