<commit_before>module Writable
  extend ActiveSupport::Concern

  included do
    belongs_to :character
    belongs_to :icon
    belongs_to :user

    attr_accessible :character, :character_id, :user, :user_id, :icon, :icon_id, :content, :created_at, :updated_at

    validates_presence_of :user
    validate :character_ownership, :icon_ownership

    def has_icons?
      return user.avatar_id? unless character
      return true if character.default_icon
      return false unless character.gallery
      return character.gallery.icons.present?
    end

    def editable_by?(editor)
      return false unless editor
      editor.id == user_id || editor.admin?
    end

    def word_count
      content.split.size
    end

    private
<commit_msg>Fix icons bug for writable<commit_after>module Writable
  extend ActiveSupport::Concern

  included do
    belongs_to :character
    belongs_to :icon
    belongs_to :user

    attr_accessible :character, :character_id, :user, :user_id, :icon, :icon_id, :content, :created_at, :updated_at

    validates_presence_of :user
    validate :character_ownership, :icon_ownership

    def has_icons?
      return user.avatar_id? unless character
      return true if character.default_icon
      return false unless character.gallery
      return character.galleries.map(&:icons).present?
    end

    def editable_by?(editor)
      return false unless editor
      editor.id == user_id || editor.admin?
    end

    def word_count
      content.split.size
    end

    private

{'fraction_non_alphanumeric': 0.06851119894598155, 'fraction_numerical': 0.0, 'mean_word_length': 3.2549019607843137, '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': '1745506', 'n_tokens_mistral': 461, 'n_tokens_neox': 445, 'n_words': 122}