Class: BranchRules::BaseService
- Inherits:
-
Object
- Object
- BranchRules::BaseService
- Includes:
- Gitlab::Allowable
- Defined in:
- app/services/branch_rules/base_service.rb
Direct Known Subclasses
Constant Summary collapse
- MISSING_METHOD_ERROR =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#branch_rule ⇒ Object
readonly
Returns the value of attribute branch_rule.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #execute(skip_authorization: false) ⇒ Object
-
#initialize(branch_rule, user = nil, params = {}) ⇒ BaseService
constructor
A new instance of BaseService.
Methods included from Gitlab::Allowable
Constructor Details
#initialize(branch_rule, user = nil, params = {}) ⇒ BaseService
Returns a new instance of BaseService.
13 14 15 16 17 |
# File 'app/services/branch_rules/base_service.rb', line 13 def initialize(branch_rule, user = nil, params = {}) @branch_rule = branch_rule @current_user = user @params = ActionController::Parameters.new(**params).permit(*permitted_params).to_h end |
Instance Attribute Details
#branch_rule ⇒ Object (readonly)
Returns the value of attribute branch_rule.
9 10 11 |
# File 'app/services/branch_rules/base_service.rb', line 9 def branch_rule @branch_rule end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
9 10 11 |
# File 'app/services/branch_rules/base_service.rb', line 9 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'app/services/branch_rules/base_service.rb', line 9 def params @params end |
Instance Method Details
#execute(skip_authorization: false) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/services/branch_rules/base_service.rb', line 19 def execute(skip_authorization: false) raise Gitlab::Access::AccessDeniedError unless || return execute_on_branch_rule if branch_rule.instance_of?(Projects::BranchRule) ServiceResponse.error(message: 'Unknown branch rule type.') end |