Exception: Checkin::AccessDenied

Inherits:
StandardError
  • Object
show all
Defined in:
lib/checkin/access_denied.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, action, object_or_resource, options = {}) ⇒ AccessDenied

Returns a new instance of AccessDenied.



27
28
29
30
31
32
33
34
35
36
# File 'lib/checkin/access_denied.rb', line 27

def initialize(subject, action, object_or_resource, options = {})
  
  @message  = options[:message]
  @subject  = subject
  @action   = action
  @object   = ( object_or_resource.is_a?(Symbol) || object_or_resource.is_a?(String)) ? nil : object_or_resource
  @resource = object ? object.class.name.demodulize.underscore.to_sym  : "#{object_or_resource}".singularize.to_sym
  
  @default_message = I18n.t(:"unauthorized.default", :default => "You are not authorized to access this page.")
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



25
26
27
# File 'lib/checkin/access_denied.rb', line 25

def action
  @action
end

#objectObject (readonly)

Returns the value of attribute object.



25
26
27
# File 'lib/checkin/access_denied.rb', line 25

def object
  @object
end

#resourceObject (readonly)

Returns the value of attribute resource.



25
26
27
# File 'lib/checkin/access_denied.rb', line 25

def resource
  @resource
end

#subjectObject (readonly)

Returns the value of attribute subject.



25
26
27
# File 'lib/checkin/access_denied.rb', line 25

def subject
  @subject
end

Instance Method Details

#scopeObject



38
39
40
# File 'lib/checkin/access_denied.rb', line 38

def scope
  @subject.scope if @subject
end

#to_sObject



42
43
44
# File 'lib/checkin/access_denied.rb', line 42

def to_s
  @message || @default_message
end