module Legacy
  class TitleProviderGroupName < ApplicationRecord
    has_many :title_provider_groups, dependent: :destroy

    before_create :initialize_data

    accepts_nested_attributes_for :title_provider_groups, allow_destroy: true

    def self.prefix
      Parameter.load('title_provider_group_name_prefix')
    end

    def self.name_with_prefix(name)
      "#{prefix}#{name}"
    end

    private

    def initialize_data
      self.country_id ||= 1
    end
  end
end
