Sha256: 95be505ce29ed3d97bcc882261d6f07263af313c07d0aab56eded9123abd74d3
Contents?: true
Size: 808 Bytes
Versions: 8
Compression:
Stored size: 808 Bytes
Contents
# typed: true # frozen_string_literal: true require 'dry/monads/result' require 'dry/validation' require 'dry/matcher/result_matcher' require 'rider_kick/use_cases/contract' module RiderKick module UseCases class AbstractUseCase include Dry::Monads[:result] def self.contract(base_contract = Contract, &proc) @contract ||= Class.new(base_contract, &proc) end def self.contract!(args) context = args.fetch(:context, {}) @results = @contract.new(context).call(args) end def initialize(contract) @contract = contract end def build_parameter! if @contract.success? Success(Hashie::Mash.new(@contract.to_h)) else Failure(@contract.errors.to_h) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems