-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Create abstract action parent class #568
Create abstract action parent class #568
Conversation
Question for code reviewer: |
def request | ||
raise NotImplementedError, 'Please implement a #request method' | ||
end | ||
|
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.
This needs to be deleted or else the code will never find abstract_action
's request method
lib/netsuite/actions/add.rb
Outdated
@@ -1,7 +1,9 @@ | |||
# https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/add.html | |||
require_relative 'abstract_action' |
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.
I don't think we need these, I'm pretty sure we can autoload
them in lib/netsuite
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.
Ahhh I didn't see that I could do that. Much cleaner.
raise NotImplementedError, 'Not implemented on abstract class' | ||
end | ||
|
||
def request_options |
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.
is there a reason we wouldn't default to {}
and omit these dup methods on the specific actions?
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.
Good call, I did this for the request_options
method. request_body
has a different implementation for each subclass so I left that one as is.
module NetSuite | ||
module Actions | ||
class AbstractAction | ||
def request(credentials={}) |
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.
can you link to this PR in a comment to help explain why this pattern is being used?
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.
I added a link to this PR to my WIP PR where I'm implementing the monkey patch for AbstractAction
. Is that what you were referring to? https://git.corp.stripe.com/stripe-internal/pay-server/pull/596685/files#r2504037
Most actions within the
actions
folder function very similarly and can be implemented by a shared parent class to reduce the repeated code. This also allows people to more easily monkey patch the functionality of all NetSuite actions in one call rather than needing to edit the functionality of every single NetSuite action.