Commit 7f16af18 authored by Toon Claes's avatar Toon Claes

Extract RepositoryOnShard concern

parent e7016722
# frozen_string_literal: true
module RepositoryOnShard
extend ActiveSupport::Concern
included do
belongs_to :shard
validates :shard, presence: true
end
def shard_name
shard&.name
end
def shard_name=(name)
self.shard = Shard.by_name(name)
end
end
# frozen_string_literal: true # frozen_string_literal: true
class PoolRepository < ActiveRecord::Base class PoolRepository < ActiveRecord::Base
belongs_to :shard include RepositoryOnShard
validates :shard, presence: true
has_many :member_projects, class_name: 'Project' has_many :member_projects, class_name: 'Project'
after_create :correct_disk_path after_create :correct_disk_path
def shard_name
shard&.name
end
def shard_name=(name)
self.shard = Shard.by_name(name)
end
private private
def correct_disk_path def correct_disk_path
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe PoolRepository do describe PoolRepository do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment