Class: Packages::Detail::PackagePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/packages/detail/package_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(package) ⇒ PackagePresenter

Returns a new instance of PackagePresenter.


6
7
8
# File 'app/presenters/packages/detail/package_presenter.rb', line 6

def initialize(package)
  @package = package
end

Instance Method Details

#detail_viewObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/presenters/packages/detail/package_presenter.rb', line 10

def detail_view
  package_detail = {
    id: @package.id,
    created_at: @package.created_at,
    name: @package.name,
    package_files: @package.package_files.map { |pf| build_package_file_view(pf) },
    package_type: @package.package_type,
    project_id: @package.project_id,
    tags: @package.tags.as_json,
    updated_at: @package.updated_at,
    version: @package.version
  }

  package_detail[:maven_metadatum] = @package.maven_metadatum if @package.maven_metadatum
  package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum
  package_detail[:composer_metadatum] = @package.composer_metadatum if @package.composer_metadatum
  package_detail[:conan_metadatum] = @package.conan_metadatum if @package.conan_metadatum
  package_detail[:dependency_links] = @package.dependency_links.map(&method(:build_dependency_links))
  package_detail[:pipeline] = build_pipeline_info(@package.build_info.pipeline) if @package.build_info

  package_detail
end