<commit_before>require 'ostruct'

module KillObject
  def self.dead_object(name, fields)
    self.class.send(:define_method, name) do |*args|
      alive_object, extra_fields = *args
      kill name, alive_object, fields, extra_fields || {}
    end
  end

  dead_object :user,
    [:id, :name, :username, :location, :biography,
     :gravatar_hash, :email, :receives_mailed_notifications,
     :receives_digest, :graph_user_id, :statistics,
     :deleted, :hidden?, :confirmed?]
  dead_object :channel,
    [:type, :title, :id, :slug_title, :created_by_id]
  dead_object :comment,
    [:id, :created_by, :created_at, :content, :type,
     :fact_data, :sub_comment_count, :created_by_id]
  dead_object :sub_comment,
    [:id, :created_by, :created_by_id, :created_at, :content, :parent_id]
  dead_object :fact_relation,
    [:id, :type, :fact, :from_fact, :created_at, :created_by,
     :opinion, :sub_comments_count, :deletable?, :created_by_id]

  def self.kill name, alive_object, take_fields, extra_fields={}
    hash = {dead_object_name: name}
    take_fields.each do |key|
      hash[key] = alive_object.send(key) if alive_object.respond_to? key
    end
    open_struct = OpenStruct.new(hash.merge extra_fields)

    open_struct.send(:define_singleton_method, :to_json) do |*args|
      table.to_json(*args)
    end

    open_struct
  end
end<commit_msg>Removed unused method KillObject.channel<commit_after>require 'ostruct'

module KillObject
  def self.dead_object(name, fields)
    self.class.send(:define_method, name) do |*args|
      alive_object, extra_fields = *args
      kill name, alive_object, fields, extra_fields || {}
    end
  end

  dead_object :user,
    [:id, :name, :username, :location, :biography,
     :gravatar_hash, :email, :receives_mailed_notifications,
     :receives_digest, :graph_user_id, :statistics,
     :deleted, :hidden?, :confirmed?]
  dead_object :comment,
    [:id, :created_by, :created_at, :content, :type,
     :fact_data, :sub_comment_count, :created_by_id]
  dead_object :sub_comment,
    [:id, :created_by, :created_by_id, :created_at, :content, :parent_id]
  dead_object :fact_relation,
    [:id, :type, :fact, :from_fact, :created_at, :created_by,
     :opinion, :sub_comments_count, :deletable?, :created_by_id]

  def self.kill name, alive_object, take_fields, extra_fields={}
    hash = {dead_object_name: name}
    take_fields.each do |key|
      hash[key] = alive_object.send(key) if alive_object.respond_to? key
    end
    open_struct = OpenStruct.new(hash.merge extra_fields)

    open_struct.send(:define_singleton_method, :to_json) do |*args|
      table.to_json(*args)
    end

    open_struct
  end
end
{'fraction_non_alphanumeric': 0.12448443944506937, 'fraction_numerical': 0.0, 'mean_word_length': 4.467213114754099, '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': '2252327', 'n_tokens_mistral': 970, 'n_tokens_neox': 949, 'n_words': 203}