Sha256: 8272754a7878eead43aa24a7d8138004d76cc3bb75ec4b1ff64c9bf79f195157

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
class SmartCore::Types::Primitive::InvariantControl::Single::Result
  # @return [SmartCore::Types::Primitive::InvariantControl::Single]
  #
  # @api private
  # @since 0.2.0
  attr_reader :invariant

  # @return [Any]
  #
  # @api private
  # @since 0.2.0
  attr_reader :checked_value

  # @param invariant [SmartCore::Types::Primitive::InvariantControl::Single]
  # @param checked_value [Any]
  # @param is_valid_check [Boolean]
  # @return [void]
  #
  # @api private
  # @since 0.2.0
  def initialize(invariant, checked_value, is_valid_check)
    @invariant = invariant
    @checked_value = checked_value
    @is_valid_check = is_valid_check
  end

  # @return [Boolean]
  #
  # @api private
  # @since 0.2.0
  def success?
    is_valid_check
  end

  # @return [Boolean]
  #
  # @api private
  # @since 0.2.0
  def failure?
    !success?
  end

  # @return [Array<String>]
  #
  # @api private
  # @since 0.2.0
  def error_codes
    success? ? [] : [invariant.name]
  end

  private

  # @return [Boolean]
  #
  # @api private
  # @since 0.2.0
  attr_reader :is_valid_check
  alias_method :valid_check?, :is_valid_check
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.7.1 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.7.0 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.6.0 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.4.0 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.3.0 lib/smart_core/types/primitive/invariant_control/single/result.rb
smart_types-0.2.0 lib/smart_core/types/primitive/invariant_control/single/result.rb