2018-10-18 23:44:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class PoolRepository < ActiveRecord::Base
|
|
|
|
belongs_to :shard
|
|
|
|
validates :shard, presence: true
|
|
|
|
|
2018-11-20 06:48:18 -05:00
|
|
|
has_many :member_projects, class_name: 'Project'
|
2018-10-18 23:44:41 -04:00
|
|
|
|
2018-11-20 06:48:18 -05:00
|
|
|
after_create :correct_disk_path
|
2018-10-18 23:44:41 -04:00
|
|
|
|
|
|
|
def shard_name
|
|
|
|
shard&.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def shard_name=(name)
|
|
|
|
self.shard = Shard.by_name(name)
|
|
|
|
end
|
2018-11-20 06:48:18 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def correct_disk_path
|
|
|
|
update(disk_path: storage.disk_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def storage
|
|
|
|
Storage::HashedProject
|
|
|
|
.new(self, prefix: Storage::HashedProject::POOL_PATH_PREFIX)
|
|
|
|
end
|
2018-10-18 23:44:41 -04:00
|
|
|
end
|