Module: Featurable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Groups::FeatureSetting, ProjectFeature
- Defined in:
- app/models/concerns/featurable.rb
Overview
Featurable concern
This concern adds features (tools) functionality to Project and Group To enable features you need to call set_available_features
Example:
class ProjectFeature
include Featurable
set_available_features %i(wiki merge_request)
Constant Summary collapse
- DISABLED =
Can be enabled only for members, everyone or disabled Access control is made only for non private containers.
Permission levels:
Disabled: not enabled for anyone Private: enabled only for team members Enabled: enabled for everyone able to access the project Public: enabled for everyone (only allowed for pages)
0- PRIVATE =
10- ENABLED =
20- PUBLIC =
30- STRING_OPTIONS =
HashWithIndifferentAccess.new({ 'disabled' => DISABLED, 'private' => PRIVATE, 'enabled' => ENABLED, 'public' => PUBLIC }).freeze
- PAGES_ACCESS_LEVELS_BY_PROJECT_VISIBILITY =
{ Gitlab::VisibilityLevel::PRIVATE => [ DISABLED, PRIVATE, PUBLIC # 'Enabled' is not allowed for private projects # because 'private' and 'enabled' pages access control settings have the same effect ].freeze, Gitlab::VisibilityLevel::INTERNAL => [ DISABLED, PRIVATE, ENABLED, PUBLIC ].freeze, Gitlab::VisibilityLevel::PUBLIC => [ DISABLED, PRIVATE, ENABLED # 'Public' is not allowed for public projects # because 'enabled' and 'public' pages access control settings have the same effect ].freeze }.freeze
Instance Method Summary collapse
- #access_level(feature) ⇒ Object
- #feature_available?(feature, user = nil) ⇒ Boolean
- #string_access_level(feature) ⇒ Object
Instance Method Details
#access_level(feature) ⇒ Object
119 120 121 |
# File 'app/models/concerns/featurable.rb', line 119 def access_level(feature) public_send(self.class.access_level_attribute(feature)) # rubocop:disable GitlabSecurity/PublicSend end |
#feature_available?(feature, user = nil) ⇒ Boolean
123 124 125 |
# File 'app/models/concerns/featurable.rb', line 123 def feature_available?(feature, user = nil) (user, feature) end |
#string_access_level(feature) ⇒ Object
127 128 129 |
# File 'app/models/concerns/featurable.rb', line 127 def string_access_level(feature) self.class.str_from_access_level(access_level(feature)) end |