Class: Package

Inherits:
ApplicationRecord show all
Defined in:
app/models/package.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.policy_classObject

Declare the policy class to use for authz


21
22
23
# File 'app/models/package.rb', line 21

def self.policy_class
  PackagePolicy
end

Instance Method Details

#bagger_profileObject


49
50
51
# File 'app/models/package.rb', line 49

def bagger_profile
  Rails.application.config.validation["bagger_profile"][content_type.to_s]
end

#dest_pathObject


29
30
31
32
33
# File 'app/models/package.rb', line 29

def dest_path
  prefixes = bag_id.match(/^(..)(..)(..).*/)
  raise "bag_id too short" unless prefixes
  File.join(Rails.application.config.upload["storage_path"], *prefixes[1..3], bag_id)
end

#external_validation_cmdObject


43
44
45
46
47
# File 'app/models/package.rb', line 43

def external_validation_cmd
  ext_cmd = Rails.application.config.validation["external"][content_type.to_s]
  return unless ext_cmd
  [ext_cmd, external_id, src_path].join(" ")
end

#resource_typeObject


53
54
55
# File 'app/models/package.rb', line 53

def resource_type
  content_type
end

#src_pathObject


25
26
27
# File 'app/models/package.rb', line 25

def src_path
  File.join(Rails.application.config.upload["upload_path"], user.username, bag_id)
end

#stored?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'app/models/package.rb', line 39

def stored?
  storage_location != nil
end

#to_paramObject


12
13
14
# File 'app/models/package.rb', line 12

def to_param
  bag_id
end

35
36
37
# File 'app/models/package.rb', line 35

def upload_link
  File.join(Rails.application.config.upload["rsync_point"], bag_id)
end