Class: Packages::CreatePackageFileService

Inherits:
Object
  • Object
show all
Defined in:
app/services/packages/create_package_file_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, params) ⇒ CreatePackageFileService

Returns a new instance of CreatePackageFileService.


6
7
8
9
# File 'app/services/packages/create_package_file_service.rb', line 6

def initialize(package, params)
  @package = package
  @params = params
end

Instance Attribute Details

#packageObject (readonly)

Returns the value of attribute package


4
5
6
# File 'app/services/packages/create_package_file_service.rb', line 4

def package
  @package
end

#paramsObject (readonly)

Returns the value of attribute params


4
5
6
# File 'app/services/packages/create_package_file_service.rb', line 4

def params
  @params
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
# File 'app/services/packages/create_package_file_service.rb', line 11

def execute
  package.package_files.create!(
    file:        params[:file],
    size:        params[:size],
    file_name:   params[:file_name],
    file_sha1:   params[:file_sha1],
    file_sha256: params[:file_sha256],
    file_md5:    params[:file_md5]
  )
end