-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement easier way to access business property from view model (tes…
…t will fail)
- Loading branch information
Showing
7 changed files
with
155 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from collections import UserDict | ||
|
||
|
||
class Struct(UserDict): | ||
|
||
def __init__(self, schema_obj): | ||
super().__init__() | ||
self.schema_obj = schema_obj | ||
|
||
@property | ||
def vals(self): | ||
for _, val in self.data.items(): | ||
if isinstance(val, dict): | ||
for _, v in val.items(): | ||
yield v | ||
else: | ||
yield val | ||
|
||
def __getitem__(self, key): | ||
""" | ||
Initializes a field to dict if it was not declared before | ||
:param item: | ||
:return: | ||
""" | ||
|
||
if key not in self.data.keys(): | ||
self.data[key] = dict() | ||
return super().__getitem__(key) | ||
|
Oops, something went wrong.