From d06d8c221be5b82d00da821323fb6d1889e58105 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 28 Dec 2017 01:04:01 +0000 Subject: simplify API to avoid (and raise on) user errors This fixes our API to match the documentation in making Msgthr#order! optional. Furthermore, the block previously passed to Msgthr#order! may now be passed to Msgthr#thread! instead. We accomplish this by tracking internal state explicitly, so a Msgthr::StateError exception will be raised when methods are called in an unsupported order. This internal state is reset with Msgthr#clear. For users who truly do not care about ordering, Msgthr#walk_thread may be called immediately after the last call to Msgthr#add. Thanks to Dimid Duchovny for the feedback which led to this: https://80x24.org/msgthr-public/CANKvuDc2mkxLuh+3+WXWfMXzxK2bShNesrD5xLocGOD1RybbwQ@mail.gmail.com/ --- lib/msgthr/container.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/msgthr/container.rb') diff --git a/lib/msgthr/container.rb b/lib/msgthr/container.rb index e51507c..fbff719 100644 --- a/lib/msgthr/container.rb +++ b/lib/msgthr/container.rb @@ -1,9 +1,9 @@ # Copyright (C) 2016 all contributors # License: GPL-2.0+ -# An internal container class, this is exposed for Msgthr#order! -# and Msgthr#walk_thread APIs. They should should not be initialized -# in your own code. +# An internal container class, this is exposed for Msgthr#thread! +# Msgthr#order! and Msgthr#walk_thread APIs through block parameters. +# They should should not be initialized in your own code. # # One container object will exist for every message you call Msgthr#add! on, # so there can potentially be many of these objects for large sets of -- cgit v1.2.3-24-ge0c7