forked from ratem/eispatterns
/
employee_decorator.py
31 lines (25 loc) · 1.07 KB
/
employee_decorator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from should_dsl import should
from domain.base.decorator import Decorator
from domain.node.person import Person
from domain.resource.operation import operation
from domain.supportive.rule import rule
from domain.supportive.association_error import AssociationError
class EmployeeDecorator(Decorator):
'''A general purpose Employee decorator'''
def __init__(self):
Decorator.__init__(self)
self.description = "Supplies the basis for representing employes"
def generate_register(self, register):
''' generates the register number for the employee '''
self.register = register
def decorate(self, decorated):
try:
EmployeeDecorator.rule_should_be_person_instance(decorated)
except:
raise AssociationError('Person instance expected, instead %s passed' % type(decorated))
self.decorated = decorated
@classmethod
@rule('association')
def rule_should_be_person_instance(self, decorated):
''' Decorated object should be a Person '''
decorated |should| be_instance_of(Person)