Sha256: 100439f425b1afc6c355d63d81ae5eb1376d6747ec35b7206197c07f8e7b3e56

Contents?: true

Size: 475 Bytes

Versions: 4

Compression:

Stored size: 475 Bytes

Contents

class CreateUserService < Aldous::Service
  attr_reader :user_data_hash

  def initialize(user_data_hash)
    @user_data_hash = user_data_hash
  end

  def raisable_error
    Aldous::Errors::UserError
  end

  def default_result_data
    {user: nil}
  end

  def perform
    user = User.new(user_data_hash)
    user.roles << Role.where(name: "account_holder").first

    if user.save
      Result::Success.new(user: user)
    else
      Result::Failure.new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aldous-1.1.3 examples/basic_todo/app/services/create_user_service.rb
aldous-1.1.2 examples/basic_todo/app/services/create_user_service.rb
aldous-1.0.1 examples/basic_todo/app/services/create_user_service.rb
aldous-1.0.0 examples/basic_todo/app/services/create_user_service.rb