<commit_before># Allows a Model to belong to more than one type of owner

module Ownable
  extend ActiveSupport::Concern

  included do 
    belongs_to :owner, polymorphic: true
    validates_presence_of :owner
  end

  def owner?(instance)
    instance.class < Owner && owner == instance
  end
end<commit_msg>Set policy class for ownable objects<commit_after># Allows a Model to belong to more than one type of owner

module Ownable
  extend ActiveSupport::Concern

  included do 
    belongs_to :owner, polymorphic: true
    validates_presence_of :owner
  end

  module ClassMethods 
    def policy_class
      OwnedObjectPolicy
    end
  end

  def owner?(instance)
    instance.class < Owner && owner == instance
  end
end
{'fraction_non_alphanumeric': 0.05234159779614325, 'fraction_numerical': 0.0, 'mean_word_length': 3.5723270440251573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '751784', 'n_tokens_mistral': 222, 'n_tokens_neox': 207, 'n_words': 79}