diff --git a/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js b/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js index 43d213b..e576acf 100644 --- a/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js +++ b/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js @@ -5,7 +5,7 @@ window.filtersExecuted = window.filtersExecuted || {before : [], after : []}; (function(){ var filter = new Paloma.FilterScope('sample_namespace/baz'); // Skip Filters From Namespace - /* + filter.skip_before_filter('All - Skip This Before Filter'); filter.skip_before_filter('Only - Skip This Before Filter'); filter.skip_before_filter('Except - Skip This Before Filter'); @@ -17,7 +17,7 @@ window.filtersExecuted = window.filtersExecuted || {before : [], after : []}; filter.skip_around_filter('All - Skip This Around Filter'); filter.skip_around_filter('Only - Skip This Around Filter'); filter.skip_around_filter('Except - Skip This Around Filter'); - */ + // Before filter.as('Standard Before'). diff --git a/vendor/assets/javascripts/paloma_core.js b/vendor/assets/javascripts/paloma_core.js index 7b3b384..d12d149 100644 --- a/vendor/assets/javascripts/paloma_core.js +++ b/vendor/assets/javascripts/paloma_core.js @@ -43,7 +43,7 @@ Paloma.execute = function(controller, action, params){ Paloma._filters = {'before' : {}, 'after' : {}, 'around' : {}}; - +Paloma._scopes = {}; Paloma._getOrderedFilters = function(before_or_after, namespace, controller, action){ var namespaceFilters = Paloma._filters[before_or_after][namespace], @@ -82,12 +82,35 @@ Paloma._performFilters = function(filters, params){ // FilterScope Class -Paloma.FilterScope = function(name){ this.name = name; }; +Paloma.FilterScope = function(name){ + this.name = name; + this.skipFilters = []; + this.skipFilterType = undefined; + this.skipType = 'all'; + + Paloma._scopes[name] = this; +}; Paloma.FilterScope.prototype.as = function(filterName){ return (new Paloma.Filter(this.name, filterName)); }; +// skip_*_filter methods +(function(){ + var types = ['before', 'after', 'around']; + for (var i = 0, n = types.length; i < n; i++){ + var type = types[i]; + Paloma.FilterScope.prototype['skip_' + type + '_filter'] = function(){ + this.skipFilterType = type; + this.skipFilters = Array.prototype.slice.call(arguments); + return this; + }; + } +})(); + +Paloma.FilterScope.prototype.only = function(){ this.skipType = 'only'; }; +Paloma.FilterScope.prototype.except = function(){ this.skipType = 'except'; }; + // Filter class