diff options
Diffstat (limited to 'app/models/packages/rubygems')
-rw-r--r-- | app/models/packages/rubygems/metadatum.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/packages/rubygems/metadatum.rb b/app/models/packages/rubygems/metadatum.rb new file mode 100644 index 00000000000..42db1f3defc --- /dev/null +++ b/app/models/packages/rubygems/metadatum.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Packages + module Rubygems + class Metadatum < ApplicationRecord + self.table_name = 'packages_rubygems_metadata' + self.primary_key = :package_id + + belongs_to :package, -> { where(package_type: :rubygems) }, inverse_of: :rubygems_metadatum + + validates :package, presence: true + + validate :rubygems_package_type + + private + + def rubygems_package_type + unless package&.rubygems? + errors.add(:base, _('Package type must be RubyGems')) + end + end + end + end +end |