Exception: Aserto::AccessDenied

Inherits:
Error
  • Object
show all
Defined in:
lib/aserto/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, action = nil, conditions = nil) ⇒ AccessDenied

Returns a new instance of AccessDenied.



12
13
14
15
16
17
18
# File 'lib/aserto/errors.rb', line 12

def initialize(message = nil, action = nil, conditions = nil)
  @message = message
  @action = action
  @conditions = conditions
  @default_message = I18n.t(:"unauthorized.default", default: "You are not authorized to access this page.")
  super()
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



9
10
11
# File 'lib/aserto/errors.rb', line 9

def action
  @action
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



9
10
11
# File 'lib/aserto/errors.rb', line 9

def conditions
  @conditions
end

#default_message=(value) ⇒ Object (writeonly)

Sets the attribute default_message

Parameters:

  • value

    the value to set the attribute default_message to.



10
11
12
# File 'lib/aserto/errors.rb', line 10

def default_message=(value)
  @default_message = value
end

Instance Method Details

#inspectObject



24
25
26
27
28
29
30
# File 'lib/aserto/errors.rb', line 24

def inspect
  details = i[action conditions message].filter_map do |attribute|
    value = instance_variable_get :"@#{attribute}"
    "#{attribute}: #{value.inspect}" if value.present?
  end.join(", ")
  "#<#{self.class.name} #{details}>"
end

#to_sObject



20
21
22
# File 'lib/aserto/errors.rb', line 20

def to_s
  @message || @default_message
end