<commit_before>module Recliner
  module ViewFunctions
    class ViewFunction
      class_inheritable_accessor :definition
    
      def initialize(body)
        if body =~ /^\s*function/
          @body = body
        else
          @body = "#{self.class.definition} { #{body} }"
        end
      end
    
      def to_s
        @body
      end
    
      def self.create(definition)
        returning Class.new(self) do |klass|
          klass.definition = definition
        end
      end
    end<commit_msg>Fix JSON serialization of view functions<commit_after>module Recliner
  module ViewFunctions
    class ViewFunction
      class_inheritable_accessor :definition
    
      def initialize(body)
        if body =~ /^\s*function/
          @body = body
        else
          @body = "#{self.class.definition} { #{body} }"
        end
      end
    
      def to_s
        "\"#{@body}\""
      end
      
      alias to_json to_s
    
      def self.create(definition)
        returning Class.new(self) do |klass|
          klass.definition = definition
        end
      end
    end
{'fraction_non_alphanumeric': 0.0815018315018315, 'fraction_numerical': 0.0, 'mean_word_length': 1.6529126213592233, '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': '6413733', 'n_tokens_mistral': 309, 'n_tokens_neox': 315, 'n_words': 79}