<commit_before>class RegisteredPath < ActiveRecord::Base

  belongs_to :provider, :polymorphic => true

  def has_user?
    PathRegistry.users.any? { |u| u.exists? u.path_registry.foreign_key => id }
  end

  def to_s
    path
  end

  validates_uniqueness_of :provider_id, :scope => :provider_type
  validates_associated :provider

  named_scope :scopeless
  named_scope :have_scope, lambda { |scope|
    { :conditions => {:scope => scope} }
  }

  after_update   { |r| PathRegistry.notify :update, self }
  after_destroy  { |r| PathRegistry.notify :destroy, self }

  protected
  def assign_scope
    klass = provider.class
    self.scope = klass.path_registry.scope provider
  end
  before_validation :assign_scope
  def assign_label
    klass = provider.class
    self.label = klass.path_registry.label provider
  end
  before_validation :assign_label
  def assign_path
    klass = provider.class<commit_msg>Use instance as parameter, not class.<commit_after>class RegisteredPath < ActiveRecord::Base

  belongs_to :provider, :polymorphic => true

  def has_user?
    PathRegistry.users.any? { |u| u.exists? u.path_registry.foreign_key => id }
  end

  def to_s
    path
  end

  validates_uniqueness_of :provider_id, :scope => :provider_type
  validates_associated :provider

  named_scope :scopeless
  named_scope :have_scope, lambda { |scope|
    { :conditions => {:scope => scope} }
  }

  after_update   { |r| PathRegistry.notify :update, r }
  after_destroy  { |r| PathRegistry.notify :destroy, r }

  protected
  def assign_scope
    klass = provider.class
    self.scope = klass.path_registry.scope provider
  end
  before_validation :assign_scope
  def assign_label
    klass = provider.class
    self.label = klass.path_registry.label provider
  end
  before_validation :assign_label
  def assign_path
    klass = provider.class
{'fraction_non_alphanumeric': 0.08686210640608034, 'fraction_numerical': 0.0, 'mean_word_length': 3.8372703412073492, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4000812', 'n_tokens_mistral': 595, 'n_tokens_neox': 584, 'n_words': 142}