Skip to content
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

Closed
wants to merge 2 commits into from
Closed

fix bug and overload method #18

wants to merge 2 commits into from

Conversation

snowliy
Copy link
Member

@snowliy snowliy commented Aug 25, 2018

  1. 🐛 fix 2 array equals' bug;
  2. 🎨 overload 3 methods.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 61

  • 0 of 12 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 48.287%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/model/model.ts 0 1 0.0%
src/enforcer.ts 0 11 0.0%
Totals Coverage Status
Change from base Build 60: 0.2%
Covered Lines: 439
Relevant Lines: 839

💛 - Coveralls

Copy link
Member

@hsluoyz hsluoyz left a 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> {
Copy link
Member

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> {
Copy link
Member

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> {
Copy link
Member

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.

Copy link
Member Author

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> {
Copy link
Member

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> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changes this?

@hsluoyz hsluoyz closed this Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants