<commit_before>module RestfulQuery
  module CanQuery
   
    def self.included(klass)
      klass.extend MacroMethods
    end

    module MacroMethods
      def can_query(options = {})
        @include       = options.delete(:include) || []
        @query_options = options
        @can_query     = true
        module_eval do
          def self.restful_query_parser(query_hash, options = {})
            RestfulQuery::Parser.new(query_hash.dup, @query_options.merge(options))
          end
          
          named_scope :restful_query, lambda {|query_hash| 
            parser = self.restful_query_parser(query_hash)
            query_hash = {}
            query_hash[:conditions] = parser.to_conditions_array if parser.has_conditions?
            query_hash[:include]    = @include if @include && !@include.empty?
            query_hash[:order]      = parser.sort_sql if parser.has_sort?
            logger.info 'Rest query:' + query_hash.inspect
            query_hash
          }
        end
      end
      
      def can_query?
        @can_query
      end
    end
    
  end
end<commit_msg>Extra dup<commit_after>module RestfulQuery
  module CanQuery
   
    def self.included(klass)
      klass.extend MacroMethods
    end

    module MacroMethods
      def can_query(options = {})
        @include       = options.delete(:include) || []
        @query_options = options
        @can_query     = true
        module_eval do
          def self.restful_query_parser(query_hash, options = {})
            RestfulQuery::Parser.new(query_hash, @query_options.merge(options))
          end
          
          named_scope :restful_query, lambda {|query_hash| 
            parser = self.restful_query_parser(query_hash)
            query_hash = {}
            query_hash[:conditions] = parser.to_conditions_array if parser.has_conditions?
            query_hash[:include]    = @include if @include && !@include.empty?
            query_hash[:order]      = parser.sort_sql if parser.has_sort?
            logger.info 'Rest query:' + query_hash.inspect
            query_hash
          }
        end
      end
      
      def can_query?
        @can_query
      end
    end
    
  end
end
{'fraction_non_alphanumeric': 0.08257299270072993, 'fraction_numerical': 0.0, 'mean_word_length': 1.9279038718291055, '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': '2110756', 'n_tokens_mistral': 622, 'n_tokens_neox': 623, 'n_words': 122}