@@ -190,6 +190,7 @@ def resolve_stubs(dispatcher, effect):
190190 return effect
191191
192192
193+ @attr .s
193194class EQDispatcher (object ):
194195 """
195196 An equality-based (constant) dispatcher.
@@ -218,12 +219,10 @@ class EQDispatcher(object):
218219 'the-result'
219220
220221 assuming MyIntent supports ``__eq__`` by value.
222+
223+ :param list mapping: A sequence of tuples of (intent, result).
221224 """
222- def __init__ (self , mapping ):
223- """
224- :param list mapping: A sequence of tuples of (intent, result).
225- """
226- self .mapping = mapping
225+ mapping = attr .ib ()
227226
228227 def __call__ (self , intent ):
229228 # Avoid hashing, because a lot of intents aren't hashable.
@@ -232,6 +231,7 @@ def __call__(self, intent):
232231 return sync_performer (lambda d , i : v )
233232
234233
234+ @attr .s
235235class EQFDispatcher (object ):
236236 """
237237 An Equality-based function dispatcher.
@@ -263,20 +263,18 @@ class EQFDispatcher(object):
263263 'the-result'
264264
265265 assuming MyIntent supports ``__eq__`` by value.
266+
267+ :param list mapping: A sequence of two-tuples of (intent, function).
266268 """
267- def __init__ (self , mapping ):
268- """
269- :param list mapping: A sequence of two-tuples of (intent, function).
270- """
271- self .mapping = mapping
269+ mapping = attr .ib ()
272270
273271 def __call__ (self , intent ):
274272 # Avoid hashing, because a lot of intents aren't hashable.
275273 for k , v in self .mapping :
276274 if k == intent :
277275 return sync_performer (lambda d , i : v (i ))
278276
279-
277+ @ attr . s
280278class SequenceDispatcher (object ):
281279 """
282280 A dispatcher which steps through a sequence of (intent, func) tuples and
@@ -302,10 +300,10 @@ class SequenceDispatcher(object):
302300 the intent being performed, or if there are no more items left in the
303301 sequence (this is standard behavior for dispatchers that don't handle an
304302 intent). This lets this dispatcher be composed easily with others.
303+
304+ :param list sequence: Sequence of (intent, fn).
305305 """
306- def __init__ (self , sequence ):
307- """:param list sequence: Sequence of (intent, fn)."""
308- self .sequence = sequence
306+ sequence = attr .ib ()
309307
310308 def __call__ (self , intent ):
311309 if len (self .sequence ) == 0 :
0 commit comments