<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Publisher</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Publisher</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/utility/publisher_rb.html">
lib/utility/publisher.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="diagram">
<map id="map" name="map">
<area shape="RECT" coords="17,17,111,61" href="Publisher.html" alt="Publisher
">
</map>
<img src="../dot/m_57_0.png" usemap="#map" border=0 alt="Module: Publisher">
</div>
<div id="description">
<p>
<a href="Publisher.html">Publisher</a> is a variation on Ruby’s
Observable. We do not keep track of any changed state; instead we assume
that by virtue of calling publish we have changed state. We do not allow
serialization of subscribers. We allow a <a
href="Publisher.html">Publisher</a> to have multiple publications and
maintain separate lists of subscribers for each one.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000399">publish</a>
<a href="#M000395">subscribe</a>
<a href="#M000398">subscriber_count</a>
<a href="#M000396">unsubscribe</a>
<a href="#M000397">unsubscribe_all</a>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000399" class="method-detail">
<a name="M000399"></a>
<div class="method-heading">
<a href="Publisher.src/M000399.html" target="Code" class="method-signature"
onclick="popupCode('Publisher.src/M000399.html');return false;">
<span class="method-name">publish</span><span class="method-args">(*arg)</span>
</a>
</div>
<div class="method-description">
<p>
If this object’s changed state is <tt>true</tt>, invoke the update
method in each currently associated subscriber in turn, passing it the
given arguments. The changed state is then set to <tt>false</tt>.
</p>
</div>
</div>
<div id="method-M000395" class="method-detail">
<a name="M000395"></a>
<div class="method-heading">
<a href="Publisher.src/M000395.html" target="Code" class="method-signature"
onclick="popupCode('Publisher.src/M000395.html');return false;">
<span class="method-name">subscribe</span><span class="method-args">(subscriber)</span>
</a>
</div>
<div class="method-description">
<p>
Add <tt>subscriber</tt> as an subscriber on this object.
<tt>subscriber</tt> will now receive notifications.
</p>
</div>
</div>
<div id="method-M000398" class="method-detail">
<a name="M000398"></a>
<div class="method-heading">
<a href="Publisher.src/M000398.html" target="Code" class="method-signature"
onclick="popupCode('Publisher.src/M000398.html');return false;">
<span class="method-name">subscriber_count</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Count of subscribers to this object.
</p>
</div>
</div>
<div id="method-M000396" class="method-detail">
<a name="M000396"></a>
<div class="method-heading">
<a href="Publisher.src/M000396.html" target="Code" class="method-signature"
onclick="popupCode('Publisher.src/M000396.html');return false;">
<span class="method-name">unsubscribe</span><span class="method-args">(subscriber)</span>
</a>
</div>
<div class="method-description">
<p>
Delete <tt>subscriber</tt> as a subscriber on this object. It will no
longer receive notifications.
</p>
</div>
</div>
<div id="method-M000397" class="method-detail">
<a name="M000397"></a>
<div class="method-heading">
<a href="Publisher.src/M000397.html" target="Code" class="method-signature"
onclick="popupCode('Publisher.src/M000397.html');return false;">
<span class="method-name">unsubscribe_all</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Delete all subscribers associated with this object.
</p>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>