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

Allow creating generic twiml nodes #357

Merged
merged 4 commits into from
Jun 19, 2018
Merged

Allow creating generic twiml nodes #357

merged 4 commits into from
Jun 19, 2018

Conversation

cjcodes
Copy link
Member

@cjcodes cjcodes commented Jun 15, 2018

  • Creates a basic class inheritance between Responses and TwiML (added)
  • Moves addText() method to parent TwiML class
  • Adds a addChild() method to anything that inherits TwiML

* Parent TwiML object
*/
/* jshint ignore:end */
function TwiML() {
Copy link
Contributor

Choose a reason for hiding this comment

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

so ... we could make this an ES6 class, right? I guess that would require some more significant changes to the generated classes, so if you want to punt then OK. But if we don't do it now, I'm not sure when we would ....

* comparisons. Save a few CPU cycles.
*/
/* jshint ignore:end */
TwiML.prototype._getPropertyName = function _getPropertyName() {
Copy link
Contributor

Choose a reason for hiding this comment

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

per our convo today, you could make this abstract (uh ... you know what I mean) and have yoyodyne inject an implementation with the right value into each child class.

*/
/* jshint ignore:end */
TwiML.prototype.toString = function toString() {
return this[this._getPropertyName()].end();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to have a non-public getXml that returns this[this._getPropertyName()] to avoid duplication?

Copy link
Member Author

Choose a reason for hiding this comment

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

Duplication of what?

Copy link
Contributor

Choose a reason for hiding this comment

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

the code this[this._getPropertyName()] appears in several places -- I thought it would be nice to have a helper method to avoid repeating it

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes, great point!

*/
/* jshint ignore:end */
TwiML.prototype._getPropertyName = function _getPropertyName() {
return this._propertyName === undefined ? 'response' : this._propertyName;
Copy link
Contributor

Choose a reason for hiding this comment

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

is it hard to get the response classes to emit a propertyName as well? this seems like kind of a weird special case

Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove this logic now, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@cjcodes cjcodes merged commit 1b35416 into master Jun 19, 2018
@cjcodes cjcodes deleted the generic-twiml-nodes branch June 19, 2018 15:49
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.

2 participants