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?

Parameters:

  • subject (Subject)

    Subject to query roles

Returns:

  • (Array<Role>)

    Role instances, associated both with subject and object

See Also:

  • Subject#roles_for


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

def accepted_roles_by(subject)
  subject.roles_for self
end

#accepts_no_role!(role_name, subject) ⇒ Object

Free specified subject of a role on this object.

Parameters:

  • role_name (Symbol, String)

    Role name

  • subject (Subject)

    Subject to remove role from

See Also:

  • Subject#has_no_role!


32
33
34
# File 'lib/acl9/model_extensions/for_object.rb', line 32

def accepts_no_role!(role_name, subject)
  subject.has_no_role! role_name, self
end

#accepts_role!(role_name, subject) ⇒ Object

Add role on the object to specified subject.

Parameters:

  • role_name (Symbol, String)

    Role name

  • subject (Subject)

    Subject to add role for

See Also:

  • Subject#has_role!


22
23
24
# File 'lib/acl9/model_extensions/for_object.rb', line 22

def accepts_role!(role_name, subject)
  subject.has_role! role_name, self
end

#accepts_role?(role_name, subject) ⇒ Boolean

Role check.

Parameters:

  • role_name (Symbol, String)

    Role name

  • subject (Subject)

    Subject to add role for

Returns:

  • (Boolean)

    Returns true if subject has a role role_name on this object.

See Also:

  • Subject#has_role?


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

def accepts_role?(role_name, subject)
  subject.has_role? role_name, self
end

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

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

Parameters:

  • subject (Subject)

    Subject to query roles

Returns:

  • (Boolean)

    Returns true if subject has any roles on this object.

See Also:

  • Subject#has_roles_for?


42
43
44
# File 'lib/acl9/model_extensions/for_object.rb', line 42

def accepts_roles_by?(subject)
  subject.has_roles_for? self
end