Sha256: 018dca33fa2a1cf1dec5a79cefc0ffbd47616530f04bf8ebdfa7c75a1dd7ed97

Contents?: true

Size: 455 Bytes

Versions: 9

Compression:

Stored size: 455 Bytes

Contents

require 'dry-monads'
require 'main/entities/user'
require 'main/import'

module Main
  module Transactions
    class RegisterUser
      include Dry::Monads::Either::Mixin

      include Main::Import['persistence.db']

      def call(params)
        if params['name']
          Right(db[:users] << Main::Entities::User.new(*params.values_at('id', 'name')))
        else
          Left(validation: 'name is missing')
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dry-web-roda-0.5.1 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.5.0 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.4.0 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.3.0 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.2.3 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.2.2 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.2.1 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.2.0 spec/dummy/apps/main/lib/main/transactions/register_user.rb
dry-web-roda-0.1.0 spec/dummy/apps/main/lib/main/transactions/register_user.rb