<commit_before># frozen_string_literal: true

module Wings
  class ActiveFedoraConverter
    def self.FileMetadataNode(resource_class) # rubocop:disable Naming/MethodName
      class_cache[resource_class] ||= Class.new(FileMetadataNode) do
        self.valkyrie_class = resource_class

        # skip reserved attributes, we assume we don't need to translate valkyrie internals
        schema = resource_class.schema.reject do |key|
          resource_class.reserved_attributes.include?(key.name) ||
            key.name == :size
        end

        Wings::ActiveFedoraConverter.apply_properties(self, schema)
      end
    end
  end

  class FileMetadataNode < ActiveFedora::Base
    property :file_set_id, predicate: ::RDF::URI.intern("http://hyrax.samvera.org/ns/wings#file_set_id")
    property :file_identifier, predicate: ::RDF::URI.intern("http://hyrax.samvera.org/ns/wings#file_identifier")

    class_attribute :valkyrie_class

    class << self
      def model_name(*)
        Hyrax::Name.new(valkyrie_class)
      end

      def to_rdf_representation
        "Wings(#{valkyrie_class})"
      end
      alias inspect to_rdf_representation
      alias to_s inspect
    end

    def indexing_service
      Hyrax::ValkyrieIndexer.for(resource: valkyrie_resource)
    end

    def to_solr
      super.tap do |doc|
        doc[:file_identifier_ssim] = file_identifier
      end
    end
  end
end
<commit_msg>Always include has_model as reserved_attribute<commit_after># frozen_string_literal: true

module Wings
  class ActiveFedoraConverter
    def self.FileMetadataNode(resource_class) # rubocop:disable Naming/MethodName
      class_cache[resource_class] ||= Class.new(FileMetadataNode) do
        self.valkyrie_class = resource_class

        # skip reserved attributes, we assume we don't need to translate valkyrie internals
        schema = resource_class.schema.reject do |key|
          resource_class.reserved_attributes.include?(key.name) ||
            key.name == :size || key.name == :has_model
        end

        Wings::ActiveFedoraConverter.apply_properties(self, schema)
      end
    end
  end

  class FileMetadataNode < ActiveFedora::Base
    property :file_set_id, predicate: ::RDF::URI.intern("http://hyrax.samvera.org/ns/wings#file_set_id")
    property :file_identifier, predicate: ::RDF::URI.intern("http://hyrax.samvera.org/ns/wings#file_identifier")

    class_attribute :valkyrie_class

    class << self
      def model_name(*)
        Hyrax::Name.new(valkyrie_class)
      end

      def to_rdf_representation
        "Wings(#{valkyrie_class})"
      end
      alias inspect to_rdf_representation
      alias to_s inspect
    end

    def indexing_service
      Hyrax::ValkyrieIndexer.for(resource: valkyrie_resource)
    end

    def to_solr
      super.tap do |doc|
        doc[:file_identifier_ssim] = file_identifier
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08590232074818151, 'fraction_numerical': 0.0, 'mean_word_length': 3.2099125364431487, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6198798', 'n_tokens_mistral': 929, 'n_tokens_neox': 877, 'n_words': 180}