Class: Cms::Group

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
DefaultAccessible
Defined in:
app/models/cms/group.rb

Overview

A group represents a collection of permissions. Each User can be assigned to one or more groups, and the sum of their permissions from all groups combined represents what they can do.

Constant Summary collapse

GUEST_CODE =
"guest"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.guestObject

Finds the guest group, which is a special group that represents public non-logged in users.


41
42
43
# File 'app/models/cms/group.rb', line 41

def self.guest
  with_code(GUEST_CODE).first
end

Instance Method Details

#cms_access?Boolean


36
37
38
# File 'app/models/cms/group.rb', line 36

def cms_access?
  group_type && group_type.cms_access?
end

#guest?Boolean


32
33
34
# File 'app/models/cms/group.rb', line 32

def guest?
  group_type && group_type.guest?
end

#has_permission?(permission) ⇒ Boolean


46
47
48
49
50
51
# File 'app/models/cms/group.rb', line 46

def has_permission?(permission)
  permissions.any? do |p|
    return true if permission.to_sym == p.name.to_sym
  end
  false
end