Class: Snippets::RepositoryValidationService
- Inherits:
-
Object
- Object
- Snippets::RepositoryValidationService
- Defined in:
- app/services/snippets/repository_validation_service.rb
Constant Summary collapse
- RepositoryValidationError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user, snippet) ⇒ RepositoryValidationService
constructor
A new instance of RepositoryValidationService.
Constructor Details
#initialize(user, snippet) ⇒ RepositoryValidationService
Returns a new instance of RepositoryValidationService.
9 10 11 12 13 |
# File 'app/services/snippets/repository_validation_service.rb', line 9 def initialize(user, snippet) @current_user = user @snippet = snippet @repository = snippet.repository end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/snippets/repository_validation_service.rb', line 5 def current_user @current_user end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
5 6 7 |
# File 'app/services/snippets/repository_validation_service.rb', line 5 def repository @repository end |
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
5 6 7 |
# File 'app/services/snippets/repository_validation_service.rb', line 5 def snippet @snippet end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/snippets/repository_validation_service.rb', line 15 def execute if snippet.nil? return service_response_error('No snippet found.', 404) end check_branch_count! check_branch_name_default! check_tag_count! check_file_count! check_size! ServiceResponse.success(message: 'Valid snippet repository.') rescue RepositoryValidationError => e ServiceResponse.error(message: "Error: #{e.}", http_status: 400) end |