Class: PolicyCheck::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/policy_check/error.rb

Overview

Model representing one error defined in the #policy block

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, message, &block) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
# File 'lib/policy_check/error.rb', line 6

def initialize(model, message, &block)
  @model = model
  @block = block
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



11
12
13
# File 'lib/policy_check/error.rb', line 11

def message
  @message
end

#modelObject (readonly)

Returns the value of attribute model.



11
12
13
# File 'lib/policy_check/error.rb', line 11

def model
  @model
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/policy_check/error.rb', line 13

def error?
  model.instance_eval(&@block)
end

#error_messageObject



17
18
19
# File 'lib/policy_check/error.rb', line 17

def error_message
  error? ? message : nil
end