Allow function argument overloading on custom JavaScript classes
This commit is contained in:
parent
612cd39b05
commit
6556de7cd2
3 changed files with 6 additions and 6 deletions
|
@ -17,7 +17,7 @@ pub mod duration {
|
|||
|
||||
impl Duration {
|
||||
#[quickjs(constructor)]
|
||||
pub fn new(value: String) -> Self {
|
||||
pub fn new(value: String, args: Rest<Value>) -> Self {
|
||||
Self {
|
||||
value,
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ pub mod duration {
|
|||
&self.value
|
||||
}
|
||||
/// Convert the object to a string
|
||||
pub fn toString(&self) -> String {
|
||||
pub fn toString(&self, args: Rest<Value>) -> String {
|
||||
self.value.to_owned()
|
||||
}
|
||||
/// Convert the object to JSON
|
||||
|
|
|
@ -19,7 +19,7 @@ pub mod record {
|
|||
|
||||
impl Record {
|
||||
#[quickjs(constructor)]
|
||||
pub fn new(tb: String, id: String) -> Self {
|
||||
pub fn new(tb: String, id: String, args: Rest<Value>) -> Self {
|
||||
Self {
|
||||
tb,
|
||||
id,
|
||||
|
@ -34,7 +34,7 @@ pub mod record {
|
|||
&self.id
|
||||
}
|
||||
/// Convert the object to a string
|
||||
pub fn toString(&self) -> String {
|
||||
pub fn toString(&self, args: Rest<Value>) -> String {
|
||||
format!("{}:{}", self.tb, self.id)
|
||||
}
|
||||
/// Convert the object to JSON
|
||||
|
|
|
@ -17,7 +17,7 @@ pub mod uuid {
|
|||
|
||||
impl Uuid {
|
||||
#[quickjs(constructor)]
|
||||
pub fn new(value: String) -> Self {
|
||||
pub fn new(value: String, args: Rest<Value>) -> Self {
|
||||
Self {
|
||||
value,
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ pub mod uuid {
|
|||
&self.value
|
||||
}
|
||||
/// Convert the object to a string
|
||||
pub fn toString(&self) -> String {
|
||||
pub fn toString(&self, args: Rest<Value>) -> String {
|
||||
self.value.to_owned()
|
||||
}
|
||||
/// Convert the object to JSON
|
||||
|
|
Loading…
Reference in a new issue