Exception: Policy::ViolationError

Inherits:
RuntimeError
  • Object
show all
Includes:
Adamantium
Defined in:
lib/policy/violation_error.rb

Overview

An exception to be risen by Interface#apply

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messagesArray<String> (readonly)

The list of messages from the broken policy

Returns:

  • (Array<String>)

19
20
21
# File 'lib/policy/violation_error.rb', line 19

def messages
  @messages
end

#policyPolicy::Follower (readonly)

The violated policy object

Returns:


13
14
15
# File 'lib/policy/violation_error.rb', line 13

def policy
  @policy
end

Class Method Details

.initialize(policy) ⇒ Policy::ViolationError

Constructs an exception

Parameters:

Returns:


29
30
31
32
# File 'lib/policy/violation_error.rb', line 29

def initialize(policy)
  @policy   = policy.dup
  @messages = @policy.messages
end

Instance Method Details

#inspectString

The human-readable description for the exception

Returns:

  • (String)

37
38
39
# File 'lib/policy/violation_error.rb', line 37

def inspect
  "#<#{ self }: #{ message }>"
end

#messageString

The human-readable exception message

Returns:

  • (String)

44
45
46
# File 'lib/policy/violation_error.rb', line 44

def message
  "#{ policy } violated: #{ messages }"
end

#new(policy) ⇒ Policy::ViolationError

Constructs an exception

Parameters:

Returns:


29
30
31
32
# File 'lib/policy/violation_error.rb', line 29

def initialize(policy)
  @policy   = policy.dup
  @messages = @policy.messages
end