<commit_before>require 'active_support/concern'

module SocialStream #:nodoc:
  module Models
    module Supertype
      extend ActiveSupport::Concern

      included do
        subtypes.each do |s|
          has_one s, :dependent => :destroy
        end
      end

      module ClassMethods
        def subtypes
          SocialStream.__send__ to_s.tableize
        end

        def load_subtype_features
          features = "SocialStream::Models::#{ to_s }".constantize

          subtypes.each do |s|
            begin
              s = s.to_s.classify.constantize
              s.__send__(:include, features) unless s.ancestors.include?(features)
            rescue
              puts "Warning: could not load #{ s }"
            end
          end
        end
      end 

      module InstanceMethods
        def subtype_instance
          self.class.subtypes.each do |s|
            i = __send__(s)
            return i if i.present?
          end

          nil
        end
      end
    end
  end
end
<commit_msg>Better warning msg when can't load subtype<commit_after>require 'active_support/concern'

module SocialStream #:nodoc:
  module Models
    module Supertype
      extend ActiveSupport::Concern

      included do
        subtypes.each do |s|
          has_one s, :dependent => :destroy
        end
      end

      module ClassMethods
        def subtypes
          SocialStream.__send__ to_s.tableize
        end

        def load_subtype_features
          features = "SocialStream::Models::#{ to_s }".constantize

          subtypes.each do |s|
            begin
              s = s.to_s.classify.constantize
              s.__send__(:include, features) unless s.ancestors.include?(features)
            rescue
              puts "Warning: could not load #{ s.to_s.classify }"
            end
          end
        end
      end 

      module InstanceMethods
        def subtype_instance
          self.class.subtypes.each do |s|
            i = __send__(s)
            return i if i.present?
          end

          nil
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06378896882494005, 'fraction_numerical': 0.0, 'mean_word_length': 1.540803897685749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5815300', 'n_tokens_mistral': 582, 'n_tokens_neox': 564, 'n_words': 158}