Sha256: 25186e28bf5b6e2e8afbc32daadaf2fbd4b29221f0d3932301af1372b4502e7e

Contents?: true

Size: 494 Bytes

Versions: 4

Compression:

Stored size: 494 Bytes

Contents

class FindCurrentUserService < Aldous::Service
  attr_reader :session

  def initialize(session)
    @session = session
  end

  def raisable_error
    Aldous::Errors::UserError
  end

  def default_result_data
    {user: nil}
  end

  def perform
    user_id = session[:user_id]
    if user_id
      user = User.where(id: user_id).first
      if user
        Result::Success.new(user: user)
      else
        Result::Failure.new
      end
    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/find_current_user_service.rb
aldous-1.1.2 examples/basic_todo/app/services/find_current_user_service.rb
aldous-1.0.1 examples/basic_todo/app/services/find_current_user_service.rb
aldous-1.0.0 examples/basic_todo/app/services/find_current_user_service.rb