mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
before,after,around methods accepting dynamic number of arguments
This commit is contained in:
parent
8d4acaaf3a
commit
d1183a9156
2 changed files with 9 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
(function(){ var filter = new Paloma.FilterScope('foo');
|
||||
|
||||
filter.as('filter A').
|
||||
before('basic action').
|
||||
before('basic action', 'callback_from_another_action').
|
||||
perform(function(params)
|
||||
{
|
||||
window.beforeFilter = 'foo/basic_action';
|
||||
|
|
12
vendor/assets/javascripts/paloma_core.js
vendored
12
vendor/assets/javascripts/paloma_core.js
vendored
|
@ -91,7 +91,7 @@ Paloma.Filter.prototype.perform = function(method){
|
|||
// Generate filter methods
|
||||
(function(){
|
||||
var Basic = function(type){
|
||||
return function(actions){ return this._setProperties(type, actions); };
|
||||
return function(){ return this._setProperties(type, arguments); };
|
||||
};
|
||||
|
||||
var All = function(type){
|
||||
|
@ -99,9 +99,9 @@ Paloma.Filter.prototype.perform = function(method){
|
|||
};
|
||||
|
||||
var Except = function(type){
|
||||
return function(actions){
|
||||
return function(){
|
||||
this.exception = true;
|
||||
return this._setProperties(type, actions);
|
||||
return this._setProperties(type, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -133,7 +133,11 @@ Paloma.Filter.prototype._addToFilters = function(){
|
|||
|
||||
|
||||
Paloma.Filter.prototype._setProperties = function(type, actions){
|
||||
// if all
|
||||
if (typeof actions === 'string'){ this.actions = actions; }
|
||||
// if arguments, convert to array
|
||||
else { this.actions = Array.prototype.slice.call(actions); }
|
||||
|
||||
this.type = type;
|
||||
this.actions = actions;
|
||||
return this;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue