Sha256: 2acb47ef325ea84c2345e014df672b1571d63ce4c8f5a6cef9f11c79ef3d71dd

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

module Pragma
  module Decorator
    module Association
      # This error is raised when an association's type is different from its type as reported by
      # the model's reflection.
      #
      # @author Alessandro Desantis
      class InconsistentTypeError < StandardError
        # Initializes the error.
        #
        # @param decorator [Base] the decorator where the association is defined
        # @param reflection [Reflection] the reflection of the inconsistent association
        # @param model_type [Symbol|String] the real type of the association
        def initialize(decorator:, reflection:, model_type:)
          message = <<~MSG.tr("\n", ' ')
            #{decorator.class}: Association #{reflection.property} is defined as #{model_type} on
            the model, but as #{reflection.type} in the decorator.
          MSG

          super message
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pragma-decorator-1.3.0 lib/pragma/decorator/association/inconsistent_type_error.rb
pragma-decorator-1.2.0 lib/pragma/decorator/association/inconsistent_type_error.rb