class TitleProviderGroup < ApplicationRecord
  include Contextuable

  belongs_to :title_provider_group_name
  belongs_to :provider
  has_many :authorizations, dependent: :destroy

  scope :hd, -> { joins(:authorizations).merge(Authorization.hd) }

  accepts_nested_attributes_for :provider
  accepts_nested_attributes_for :authorizations, allow_destroy: true

  def permission_label_ids
    authorizations.pluck(:permission_label_id)
  end
end
