<commit_before>module Rolify
  
  module Adapter
    
    class Mongoid < Adapter::Base
      
      def self.find(relation, role_name, resource)
        query = build_query(role_name, resource)
        puts "#{query.inspect}"
        criteria = relation.where(query.pop)
        query.each do |condition|
          criteria = criteria.or(condition)
          puts "#{condition}: #{criteria.inspect}"
        end
        puts "#{criteria.inspect}"
        criteria
      end
      
      def self.where(relation, args)
        conditions = build_conditions(relation, args)<commit_msg>fixing find method for mongoid adapter specs pass now successfully optimization to be done on mongoid queries though, right now the adapter does several queries for just 1 role check closes #23<commit_after>module Rolify
  
  module Adapter
    
    class Mongoid < Adapter::Base
      
      def self.find(relation, role_name, resource)
        query = build_query(role_name, resource)
        query.each do |condition|
          criteria = relation.where(condition)
          return criteria.all if !criteria.empty?
        end
        []
      end
      
      def self.where(relation, args)
        conditions = build_conditions(relation, args)
{'fraction_non_alphanumeric': 0.07711038961038962, 'fraction_numerical': 0.002435064935064935, 'mean_word_length': 2.434540389972145, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4714477', 'n_tokens_mistral': 329, 'n_tokens_neox': 330, 'n_words': 98}