<commit_before>module ActsAsContentItem
  extend ActiveSupport::Concern
 
  module ClassMethods
    def acts_as_content_item(options = {})
      Outline::ContentItems.register_class(self)
      if options[:not_postable_directly]
        Outline::ContentItems.not_postable_directly(self)
      end
      instance_eval do
        acts_as_owned_by_user
        
        belongs_to :outer_content, :class_name => "Content", :foreign_key => "content_id"
        has_one :content_item, :as => :item, :dependent => :destroy

        after_create do |item|
          content_item = ContentItem.create!(:item => item, :content => item.outer_content)
          content_item.move_to_top
        end
        after_save do |item|
          if item.content_item.content_id != item.content_id
            item.content_item.update_attribute :content_id, item.content_id
          end
        end

        validates_presence_of :outer_content
      end
    end
  end<commit_msg>Touch Content when any resource acting as its content_item is updated<commit_after>module ActsAsContentItem
  extend ActiveSupport::Concern
 
  module ClassMethods
    def acts_as_content_item(options = {})
      Outline::ContentItems.register_class(self)
      if options[:not_postable_directly]
        Outline::ContentItems.not_postable_directly(self)
      end
      instance_eval do
        acts_as_owned_by_user
        
        belongs_to :outer_content, :class_name => "Content", :foreign_key => "content_id", :touch => true
        has_one :content_item, :as => :item, :dependent => :destroy

        after_create do |item|
          content_item = ContentItem.create!(:item => item, :content => item.outer_content)
          content_item.move_to_top
        end
        after_save do |item|
          if item.content_item.content_id != item.content_id
            item.content_item.update_attribute :content_id, item.content_id
          end
        end

        validates_presence_of :outer_content
      end
    end
  end
{'fraction_non_alphanumeric': 0.07823470411233702, 'fraction_numerical': 0.0, 'mean_word_length': 2.8072519083969465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '3387817', 'n_tokens_mistral': 591, 'n_tokens_neox': 580, 'n_words': 119}