Sha256: 3b56f8441ba4ff4c9a9f515493bcc6ab58d8d0d629e3093bc04f4a148635721b
Contents?: true
Size: 1.16 KB
Versions: 7
Compression:
Stored size: 1.16 KB
Contents
require "monban/core" require "monban/use_case/base" require "getto/params" module Monban module UseCase module Account class Register < Base initialize_with( error: Monban::Core::ERRORS, time: [:now], repository: [ :transaction, :login_id_exists?, :insert_account, :update_login_id, ], ) def create(params) Getto::Params.new.validate(params) do |v| v.hash( login_id: v.combine([v.string, v.not_empty]){|val| param_error!(login_id: val) }, ) end or param_error!(params: params) repository.transaction do if repository.login_id_exists?(login_id: params[:login_id]) error.conflict! "login_id already exists" end account_id = repository.insert_account( now: time.now, ) repository.update_login_id( account_id: account_id, login_id: params[:login_id], now: time.now, ) account_id end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems