<commit_before>require 'virtus'

module Effective
  module Snippets
    class Snippet
      include Virtus.model

      attr_accessor :attributes
      attr_accessor :options

      attribute :id, String # This will be snippet_12345
      attribute :region, Effective::Region # The region Object

      def initialize(attributes = {}, options = {})
        @attributes ||= attributes
        @options ||= options

        (@attributes || []).each { |k, v| self.send("#{k}=", v) if respond_to?("#{k}=") }
      end

      def id
        super.presence || "snippet_#{object_id}"
      end

      def data
        self.attributes.reject { |k, v| ['region', 'id', 'class_name'].include?(k) }
      end

      def to_partial_path
        "effective/snippets/#{class_name}/#{class_name}"
      end

      def class_name
        @class_name ||= self.class.name.demodulize.underscore.to_sym
      end

      ### The following methods are used for the CKEditor widget creation.<commit_msg>Clean up Snippets model<commit_after>require 'virtus'

module Effective
  module Snippets
    class Snippet
      include Virtus.model

      attribute :id, String # This will be snippet_12345
      attribute :region, Effective::Region # The region Object

      def initialize(atts = {})
        (atts || {}).each { |k, v| self.send("#{k}=", v) if respond_to?("#{k}=") }
      end

      def id
        super.presence || "snippet_#{object_id}"
      end

      def data
        self.attributes.reject { |k, v| [:region, :id].include?(k) }
      end

      def to_partial_path
        "effective/snippets/#{class_name}/#{class_name}"
      end

      def class_name
        @class_name ||= self.class.name.demodulize.underscore.to_sym
      end

      ### The following methods are used for the CKEditor widget creation.
{'fraction_non_alphanumeric': 0.12, 'fraction_numerical': 0.005555555555555556, 'mean_word_length': 2.5313725490196077, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5311672', 'n_tokens_mistral': 564, 'n_tokens_neox': 532, 'n_words': 144}