refactor: variable names
This commit is contained in:
parent
9e78920497
commit
3342ef5332
1 changed files with 13 additions and 7 deletions
|
|
@ -78,22 +78,28 @@ impl ObjectInstance {
|
|||
// destination_parts[1] is the property under `input` (value)
|
||||
let destination_parts: Vec<&str> = destination.splitn(2, ":").collect();
|
||||
|
||||
// first item of tuple is for the source object template, second is for the source object instance
|
||||
let source_category = match source_parts[0] {
|
||||
"input" => (template.input, &obj.input),
|
||||
"local" => (template.local, &obj.local),
|
||||
"remote" => (template.remote, &obj.remote),
|
||||
let source_instance_category = match source_parts[0] {
|
||||
"input" => &obj.input,
|
||||
"local" => &obj.local,
|
||||
"remote" => &obj.remote,
|
||||
_ => return Err(format!("the category specified in the transformation source ({}) is invalid (must be input OR local OR remote)", source_parts[0]))
|
||||
};
|
||||
|
||||
let template_property = match source_category.0.get(source_parts[1]) {
|
||||
let source_template_category = match source_parts[0] {
|
||||
"input" => template.input,
|
||||
"local" => template.local,
|
||||
"remote" => template.remote,
|
||||
_ => unreachable!()
|
||||
};
|
||||
|
||||
let template_property = match source_template_category.get(source_parts[1]) {
|
||||
Some(template_property) => template_property,
|
||||
None => return Err(format!("the property specified as the transformation source ({}) doesn't exist in the template", source))
|
||||
};
|
||||
|
||||
if template_property.transforms.contains(&destination.to_string()) {
|
||||
let result = ObjectInstance::from_template(destination_parts[0], json!({
|
||||
destination_parts[1]: source_category.1.get(source_parts[1])
|
||||
destination_parts[1]: source_instance_category.get(source_parts[1])
|
||||
}))?;
|
||||
|
||||
Ok(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue