Class: Ci::Catalog::Listing

Inherits:
Object
  • Object
show all
Defined in:
app/models/ci/catalog/listing.rb

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


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