text: // Generated by LiveScript 1.2.0
  (function(){
    var Debugger, permitFor, RulesFileLoader, PermitRulesLoader, toString$ = {}.toString;
    Debugger = require('../../../util').Debugger;
    permitFor = require('../../factory').permitFor;
    Array.prototype.contains = function(v){
      return this.indexOf(v) > -1;
    };
    RulesFileLoader = require('./rules_file_loader');
    module.exports = PermitRulesLoader = (function(){
      PermitRulesLoader.displayName = 'PermitRulesLoader';
      var prototype = PermitRulesLoader.prototype, constructor = PermitRulesLoader;
      importAll$(prototype, arguments[0]);
      function PermitRulesLoader(filePath, options){
        this.filePath = filePath;
        this.options = options != null
          ? options
          : {};
        this.loadedRules = {};
        this.fileLoader = new RulesFileLoader(this.filePath, this.loadedRulesCallback, this.options);
      }
      prototype.load = function(async){
        return this.fileLoader.loadRules(async);
      };
      prototype.loadedRulesCallback = function(rules){
        this.loadedRules = rules;
        return this.processRules();
      };
      prototype.createPermit = function(name, options){
        var baseClazz, loadedRules, permit;
        options == null && (options = {});
        baseClazz || (baseClazz = options.clazz || requires.lib('permit'));
        loadedRules = this.loadRules().rules();
        permit = permitFor(baseClazz, name, function(){
          return {
            rules: {}
          };
        });
        if (options.key) {
          return permit.rules[key] = loadedRules;
        } else {
          return permit.rules = loadedRules;
        }
      };
      prototype.processRules = function(){
        var key, ref$, rule;
        this.debug("processRules", this.loadedRules);
        if (toString$.call(this.loadedRules).slice(8, -1) !== 'Object') {
          throw Error("Rules not loaded or invalid: " + this.loadedRules);
        }
        this.processedRules = {};
        for (key in ref$ = this.loadedRules) {
          rule = ref$[key];
          this.processRule(key, rule);
        }
        return this.processedRules;
      };
      prototype.createRulesAt = function(permit, place){
        if (toString$.call(permit).slice(8, -1) !== 'Function') {
          throw Error("Not a permit, was: " + permit);
        }
        if (place != null) {
          if (!(permit.rules != null && toString$.call(permit.rules).slice(8, -1) === 'Object')) {
            throw Error("Permit has no rules object to place loaded rules at " + place);
          }
          return permit.rules[place] = this.processedRules;
        } else {
          return permit.rules = this.processedRules;
        }
      };
      prototype.rules = function(){
        return this.processedRules;
      };
      return PermitRulesLoader;
    }(Debugger));
    function importAll$(obj, src){
      for (var key in src) obj[key] = src[key];
      return obj;
    }
  }).call(this);
  