Module: Acl9::ModelExtensions::ForObject

Defined in:
lib/acl9/model_extensions/for_object.rb

Instance Method Summary collapse

Instance Method Details

#accepted_roles_by(subject) ⇒ Array<Role>

Which roles does subject have on this object?

See Also:

  • Subject#roles_for


66
67
68
69
70
71
# File 'lib/acl9/model_extensions/for_object.rb', line 66

def accepted_roles_by(subject)
  if not subject.nil?
    return subject.roles_for self
  end
  false
end

#accepts_no_role!(role_name, subject) ⇒ Object

Free specified subject of a role on this object.

See Also:

  • Subject#has_no_role!


38
39
40
41
42
43
# File 'lib/acl9/model_extensions/for_object.rb', line 38

def accepts_no_role!(role_name, subject)
  if not subject.nil?
    return subject.has_no_role! role_name, self
  end
  false
end

#accepts_role!(role_name, subject) ⇒ Object

Add role on the object to specified subject.

See Also:

  • Subject#has_role!


25
26
27
28
29
30
# File 'lib/acl9/model_extensions/for_object.rb', line 25

def accepts_role!(role_name, subject)
  if not subject.nil?
    return subject.has_role! role_name, self
  end
  false
end

#accepts_role?(role_name, subject) ⇒ Boolean

Role check.

See Also:

  • Subject#has_role?


12
13
14
15
16
17
# File 'lib/acl9/model_extensions/for_object.rb', line 12

def accepts_role?(role_name, subject)
  if not subject.nil?
    return subject.has_role? role_name, self
  end
  false
end

#accepts_roles_by?(subject) ⇒ Boolean Also known as: accepts_role_by?

Are there any roles for the specified subject on this object?

See Also:

  • Subject#has_roles_for?


51
52
53
54
55
56
# File 'lib/acl9/model_extensions/for_object.rb', line 51

def accepts_roles_by?(subject)
  if not subject.nil?
    return subject.has_roles_for? self
  end
  false
end