Class: Perm::Authorized

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/perm/authorized.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject) ⇒ Authorized

Returns a new instance of Authorized.

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/perm/authorized.rb', line 7

def initialize(subject)
  raise ArgumentError.new("subject cannot be nil") if subject.nil?
  super @subject = subject
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



18
19
20
21
# File 'lib/perm/authorized.rb', line 18

def method_missing(name, *args)
  return false if can_method?(name)
  super
end

Instance Attribute Details

#subjectObject (readonly)

Returns the value of attribute subject.



5
6
7
# File 'lib/perm/authorized.rb', line 5

def subject
  @subject
end

Instance Method Details

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/perm/authorized.rb', line 23

def respond_to?(name)
  return true if can_method?(name)
  super
end

#userObject

Deprecated.

Please use #subject instead



13
14
15
16
# File 'lib/perm/authorized.rb', line 13

def user
  warn "The #user method has been deprecated in favor of #subject"
  subject
end