Class: Ci::Catalog::Listing
- Inherits:
-
Object
- Object
- Ci::Catalog::Listing
- Defined in:
- app/models/ci/catalog/listing.rb
Instance Method Summary collapse
-
#initialize(namespace, current_user) ⇒ Listing
constructor
This class is the SSoT to displaying the list of resources in the CI/CD Catalog given a namespace as a scope.
- #resources(sort: nil) ⇒ Object
Constructor Details
#initialize(namespace, current_user) ⇒ Listing
This class is the SSoT to displaying the list of resources in the CI/CD Catalog given a namespace as a scope. This model is not directly backed by a table and joins catalog resources with projects to return relevant data.
10 11 12 13 14 15 |
# File 'app/models/ci/catalog/listing.rb', line 10 def initialize(namespace, current_user) raise ArgumentError, 'Namespace is not a root namespace' unless namespace.root? @namespace = namespace @current_user = current_user end |
Instance Method Details
#resources(sort: nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/ci/catalog/listing.rb', line 17 def resources(sort: nil) case sort.to_s when 'name_desc' then all_resources.order_by_name_desc when 'name_asc' then all_resources.order_by_name_asc else all_resources.order_by_created_at_desc end end |