-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix bug and overload method #18
Conversation
snowliy
commented
Aug 25, 2018
- 🐛 fix 2 array equals' bug;
- 🎨 overload 3 methods.
Pull Request Test Coverage Report for Build 61
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain your changes.
@@ -511,8 +511,9 @@ export class Enforcer { | |||
/** | |||
* addPolicy adds a rule to the current policy. | |||
*/ | |||
public async addPolicy(sec: string | any[], key?: string, rule?: string[]): Promise<boolean> { | |||
if (typeof sec === 'string' && key && rule) { | |||
public async addPolicy(...params: any[]): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed? The parameters become unclear now.
} | ||
} | ||
|
||
/** | ||
* removePolicy removes a rule from the current policy. | ||
*/ | ||
public async removePolicy(sec: string | any[], key?: string, rule?: string[]): Promise<boolean> { | ||
if (typeof sec === 'string' && key && rule) { | ||
public async removePolicy(...params: any[]): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed? The parameters become unclear now.
public async removeFilteredPolicy(sec: string | number, key: string | string[], fieldIndex?: number, fieldValues?: string[]): Promise<boolean> { | ||
if (typeof sec === 'string' && typeof key === 'string' && fieldIndex && fieldValues instanceof Array) { | ||
// public async removeFilteredPolicy(sec: string | number, key: string | string[], fieldIndex?: number, fieldValues?: string[]): Promise<boolean> { | ||
public async removeFilteredPolicy(...params: any[]): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed? The parameters become unclear now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like go APIs:
In Public AddPolicy method, overload private addPolicy method.
@@ -807,7 +808,7 @@ export class Enforcer { | |||
* @param params the "p" policy rule. | |||
* @return succeeds or not. | |||
*/ | |||
public async addNamedPolicy(ptype: string, params: any[]): Promise<boolean> { | |||
public async addNamedPolicy(ptype: string, ...params: any[]): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changes this?
@@ -825,7 +826,7 @@ export class Enforcer { | |||
* @param params the "p" policy rule. | |||
* @return succeeds or not. | |||
*/ | |||
public async removeNamedPolicy(ptype: string, params: any[]): Promise<boolean> { | |||
public async removeNamedPolicy(ptype: string, ...params: any[]): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changes this?