Sha256: 5dab5fead23fca375a6fc80d77fe6ec5be581e6b993dc01766851009f0da43ef

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'dry-monads'
require 'dry/matcher/result_matcher'
require 'duckface'

module CleanArchitecture
  module Entities
    class UseCaseHistoryEntry
      implements_interface Interfaces::UseCaseHistoryEntry
      extend Forwardable

      def initialize(use_case_class, use_case_parameters, use_case_result, use_case_target)
        @use_case_class = use_case_class
        @use_case_parameters = use_case_parameters
        @use_case_result = use_case_result
        @use_case_target = use_case_target
      end

      def extra_parameters_hash
        @use_case_parameters.extra_parameters_hash
      end

      def failure_messages
        Dry::Matcher::ResultMatcher.call(@use_case_result) do |matcher|
          matcher.success { nil }
          matcher.failure { |value| value }
        end
      end

      def prior_target_state
        @use_case_target.attribute_hash
      end

      def succeeded?
        @use_case_result.success?
      end

      def target_identifier
        @use_case_target.identifier
      end

      def use_case_class_name
        @use_case_class.name
      end

      def user_identifier
        @use_case_parameters.actor.user_identifier
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clean-architecture-0.0.4 lib/clean_architecture/entities/use_case_history_entry.rb
clean-architecture-0.0.3 lib/clean_architecture/entities/use_case_history_entry.rb
clean-architecture-0.0.1 lib/clean_architecture/entities/use_case_history_entry.rb