forked from ratem/eispatterns
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of RuleChecker, refactored, nice use of sintax sugar in…
… spec
- Loading branch information
Showing
8 changed files
with
24 additions
and
13 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
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
#operation is a Python Decorator which is applied to Node/Person and Node/Machine methods | ||
|
||
''' | ||
operation is a Python Decorator which is applied to Node/Person and Node/Machine | ||
methods to mark them as business operations. The decorated method must have a | ||
docstring | ||
''' | ||
|
||
def operation(**attributes): | ||
def add_attributes(method): | ||
#add attributes to the method | ||
for attr in attributes: | ||
setattr(method, attr, attributes[attr]) | ||
#forces the method to have a docstring | ||
if method.__doc__ == None: | ||
raise KeyError | ||
raise ValueError('Operation must have a docstring') | ||
return method | ||
return add_attributes | ||
|
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#rule is a Python Decorator to typify methods as rule of association | ||
|
||
''' | ||
Rule is a Python Decorator to typify methods as rule of association, for them to | ||
work with Configurator module, @classmethod must also be applyed. If the method | ||
doesn't have a docstring, raises exception. | ||
''' | ||
|
||
def rule(rule_category): | ||
def add_attribute(method): | ||
setattr(method, 'rule_category', rule_category) | ||
if method.__doc__ == None: | ||
raise ValueError('Rule must have a docstring') | ||
return method | ||
return add_attribute | ||
|