<commit_before>module Rolify
  module Configure
    @@dynamic_shortcuts = false
    @@orm = "active_record"
     
    def configure(*role_cnames)
      return if !sanity_check(role_cnames)
      yield self if block_given?
    end

    def dynamic_shortcuts
      @@dynamic_shortcuts
    end

    def dynamic_shortcuts=(is_dynamic)
      @@dynamic_shortcuts = is_dynamic
    end

    def orm
      @@orm
    end

    def orm=(orm)
      @@orm = orm
    end

    def use_mongoid
      self.orm = "mongoid"
    end
    
    def use_dynamic_shortcuts
      self.dynamic_shortcuts = true #if defined?(Rails::Server) || defined?(Rails::Console)
    end

    def use_defaults
      configure do |config|
        config.dynamic_shortcuts = false
        config.orm = "active_record"
      end
    end
    
    private
    
    def sanity_check(role_cnames)
      role_cnames = [ "Role" ] if role_cnames.empty?
      role_cnames.each do |role_cname|
        if !role_cname.constantize.table_exists? 
          warn "[WARN] table '#{role_cname}' doesn't exist. Did you run the migration ? Ignoring rolify config."
          return false
        end
      end
      true
    end
  end
end<commit_msg>fixed sanity check in configure block when using Mongoid (no need for migration requirement) refs #113<commit_after>module Rolify
  module Configure
    @@dynamic_shortcuts = false
    @@orm = "active_record"
     
    def configure(*role_cnames)
      return if !sanity_check(role_cnames)
      yield self if block_given?
    end

    def dynamic_shortcuts
      @@dynamic_shortcuts
    end

    def dynamic_shortcuts=(is_dynamic)
      @@dynamic_shortcuts = is_dynamic
    end

    def orm
      @@orm
    end

    def orm=(orm)
      @@orm = orm
    end

    def use_mongoid
      self.orm = "mongoid"
    end
    
    def use_dynamic_shortcuts
      self.dynamic_shortcuts = true #if defined?(Rails::Server) || defined?(Rails::Console)
    end

    def use_defaults
      configure do |config|
        config.dynamic_shortcuts = false
        config.orm = "active_record"
      end
    end
    
    private
    
    def sanity_check(role_cnames)
      role_cnames = [ "Role" ] if role_cnames.empty?
      role_cnames.each do |role_cname|
        role_class = role_cname.constantize
        if role_class.superclass == ActiveRecord && !role_class.table_exists?
          warn "[WARN] table '#{role_cname}' doesn't exist. Did you run the migration ? Ignoring rolify config."
          return false
        end
      end
      true
    end
  end
end
{'fraction_non_alphanumeric': 0.07443875541551792, 'fraction_numerical': 0.0011815675462780622, 'mean_word_length': 2.3116036505867013, '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': '6165224', 'n_tokens_mistral': 830, 'n_tokens_neox': 783, 'n_words': 206}