Sha256: 0be15faf40ea9dc925c0641d35e1e2bd756b1a7249e9852a3784526bbbecc6bd

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

module Policy

  module Follower

    # An exception to be risen when a policy name is not followed by a follower
    class NameError < RuntimeError

      # @!scope class
      # @!method new(follower, name)
      # Constructs an exception for the follower class and the policy name
      #
      # @param [Class] follower
      # @param [#to_sym] name
      #
      # @return [Policy::Follower::NameError]
      def initialize(follower, name)
        @follower = follower
        @name = name.to_sym
      end

      # @!attribute [r] follower
      # The follower class that doesn't follow given policy
      #
      # @return [Class]
      attr_reader :follower

      # @!attribute [r] name
      # The name of the policy that is not followed by the follower
      #
      # @return [String]
      attr_reader :name

      # The human-readable exception message
      #
      # @return [String]
      def message
        "#{ follower.inspect } hasn't registered the policy \"#{ name }\""
      end

      # The human-readable description for the exception
      #
      # @return [String]
      def inspect
        "#<#{ self }: #{ message }>"
      end

    end # class NameError

  end # module Follower

end # module Policy

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
policy-2.0.0 lib/policy/follower/name_error.rb