Exception: Policy::Follower::ViolationError

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

Overview

An exception to be risen when a follower violates its policy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#followerObject (readonly)

The follower object that causes the exception

Returns:

  • (Object)


27
28
29
# File 'lib/policy/follower/violation_error.rb', line 27

def follower
  @follower
end

#policyPolicy::Base (readonly)

The violated policy object

Returns:



33
34
35
# File 'lib/policy/follower/violation_error.rb', line 33

def policy
  @policy
end

Class Method Details

.initialize(follower, policy) ⇒ Policy::ViolationError

Constructs an exception for the policy violated by the follower

Parameters:

  • follower (Object)
  • policy (#errors)

Returns:

  • (Policy::ViolationError)


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

def initialize(follower, policy)
  @follower = follower
  @policy = policy
end

Instance Method Details

#errorsActiveModel::Errors

Returns the list of policy errors

Returns:

  • (ActiveModel::Errors)


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

def errors
  policy.errors
end

#inspectString

The human-readable description for the exception

Returns:

  • (String)


52
53
54
# File 'lib/policy/follower/violation_error.rb', line 52

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

#messageString

The human-readable exception message

Returns:

  • (String)


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

def message
  "#{ follower.inspect } violates the policy #{ policy }"
end

#new(follower, policy) ⇒ Policy::ViolationError

Constructs an exception for the policy violated by the follower

Parameters:

  • follower (Object)
  • policy (#errors)

Returns:

  • (Policy::ViolationError)


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

def initialize(follower, policy)
  @follower = follower
  @policy = policy
end