mack-distributed 0.7.0.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/doc/classes/Mack/Distributable.html +137 -0
  2. data/doc/classes/Mack/Distributed/Errors/ApplicationNameUndefined.html +118 -0
  3. data/doc/classes/Mack/Distributed/Errors/InvalidAddressableURIFormat.html +152 -0
  4. data/doc/classes/Mack/Distributed/Errors/UnknownApplication.html +155 -0
  5. data/doc/classes/Mack/Distributed/Errors/UnknownRouteName.html +156 -0
  6. data/doc/classes/Mack/Distributed/Routes/Urls.html +213 -0
  7. data/doc/classes/Mack/Distributed/Utils/Rinda.html +230 -0
  8. data/doc/classes/Mack/Distributed/View.html +221 -0
  9. data/doc/classes/Mack/Distributed/ViewCache.html +170 -0
  10. data/doc/classes/Mack/Rendering/Type/Distributed.html +173 -0
  11. data/doc/classes/Mack/Rendering/Type/Layout.html +174 -0
  12. data/doc/classes/Mack/Routes/Urls.html +165 -0
  13. data/doc/created.rid +1 -0
  14. data/doc/files/README.html +272 -0
  15. data/doc/files/lib/mack-distributed/distributable_rb.html +101 -0
  16. data/doc/files/lib/mack-distributed/distributed_rb.html +101 -0
  17. data/doc/files/lib/mack-distributed/errors/errors_rb.html +101 -0
  18. data/doc/files/lib/mack-distributed/extensions/route_map_rb.html +101 -0
  19. data/doc/files/lib/mack-distributed/extensions/urls_rb.html +101 -0
  20. data/doc/files/lib/mack-distributed/routes/urls_rb.html +101 -0
  21. data/doc/files/lib/mack-distributed/utils/rinda_rb.html +101 -0
  22. data/doc/files/lib/mack-distributed/views/rendering/type/distributed_rb.html +101 -0
  23. data/doc/files/lib/mack-distributed/views/rendering/type/layout_rb.html +101 -0
  24. data/doc/files/lib/mack-distributed/views/view_cache_rb.html +101 -0
  25. data/doc/files/lib/mack-distributed/views/view_rb.html +101 -0
  26. data/doc/files/lib/mack-distributed_rb.html +110 -0
  27. data/doc/files/lib/mack-distributed_tasks_rb.html +107 -0
  28. data/doc/fr_class_index.html +38 -0
  29. data/doc/fr_file_index.html +40 -0
  30. data/doc/fr_method_index.html +43 -0
  31. data/doc/index.html +24 -0
  32. data/doc/rdoc-style.css +208 -0
  33. data/lib/mack-distributed.rb +0 -5
  34. data/lib/mack-distributed_tasks.rb +4 -0
  35. metadata +38 -5
@@ -0,0 +1,174 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Mack::Rendering::Type::Layout</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Mack::Rendering::Type::Layout</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../../files/lib/mack-distributed/views/rendering/type/layout_rb.html">
59
+ lib/mack-distributed/views/rendering/type/layout.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000001">render</a>&nbsp;&nbsp;
90
+ </div>
91
+ </div>
92
+
93
+ </div>
94
+
95
+
96
+ <!-- if includes -->
97
+
98
+ <div id="section">
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <!-- if method_list -->
108
+ <div id="methods">
109
+ <h3 class="section-bar">Public Instance methods</h3>
110
+
111
+ <div id="method-M000001" class="method-detail">
112
+ <a name="M000001"></a>
113
+
114
+ <div class="method-heading">
115
+ <a href="#M000001" class="method-signature">
116
+ <span class="method-name">render</span><span class="method-args">()</span>
117
+ </a>
118
+ </div>
119
+
120
+ <div class="method-description">
121
+ <p><a class="source-toggle" href="#"
122
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000001-source">
124
+ <pre>
125
+ <span class="ruby-comment cmt"># File lib/mack-distributed/views/rendering/type/layout.rb, line 10</span>
126
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>
127
+ 11: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:layout</span>].<span class="ruby-identifier">starts_with?</span>(<span class="ruby-value str">&quot;distributed&quot;</span>)
128
+ 12: <span class="ruby-comment cmt"># this is the regular layout, so call the local_render method</span>
129
+ 13: <span class="ruby-identifier">old_render</span>
130
+ 14: <span class="ruby-keyword kw">else</span>
131
+ 15: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:layout</span>])
132
+ 16: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidAddressableURIFormat</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self.options[:layout]}&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span>
133
+ 17:
134
+ 18: <span class="ruby-identifier">app_name</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
135
+ 19: <span class="ruby-identifier">resource</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;app&quot;</span>, <span class="ruby-value str">&quot;views&quot;</span>, <span class="ruby-value str">&quot;layouts&quot;</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
136
+ 20:
137
+ 21: <span class="ruby-identifier">data</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Distributed</span><span class="ruby-operator">::</span><span class="ruby-constant">View</span>.<span class="ruby-identifier">ref</span>(<span class="ruby-identifier">app_name</span>)
138
+ 22: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>
139
+ 23: <span class="ruby-identifier">raw</span> = <span class="ruby-value str">&quot;&quot;</span>
140
+ 24: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Rendering</span><span class="ruby-operator">::</span><span class="ruby-constant">Engine</span><span class="ruby-operator">::</span><span class="ruby-constant">Registry</span>.<span class="ruby-identifier">engines</span>[<span class="ruby-identifier">:layout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
141
+ 25: <span class="ruby-ivar">@engine</span> = <span class="ruby-identifier">find_engine</span>(<span class="ruby-identifier">e</span>).<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">view_template</span>)
142
+ 26:
143
+ 27: <span class="ruby-identifier">layout_path</span> = <span class="ruby-node">&quot;#{resource}.#{self.options[:format]}.#{@engine.extension}&quot;</span>
144
+ 28: <span class="ruby-identifier">raw</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">layout_path</span>)
145
+ 29: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">raw</span>.<span class="ruby-identifier">nil?</span>
146
+ 30: <span class="ruby-keyword kw">end</span>
147
+ 31:
148
+ 32: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">ResourceNotFound</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self.options[:distributed]}&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">raw</span>.<span class="ruby-identifier">nil?</span>
149
+ 33:
150
+ 34: <span class="ruby-identifier">old_render_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">view_template</span>.<span class="ruby-identifier">render_value</span>.<span class="ruby-identifier">dup</span>
151
+ 35: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">view_template</span>.<span class="ruby-identifier">render_value</span> = <span class="ruby-identifier">raw</span>
152
+ 36: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Rendering</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Inline</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">view_template</span>).<span class="ruby-identifier">render</span>
153
+ 37: <span class="ruby-comment cmt"># self.view_template.render_value = old_render_value</span>
154
+ 38: <span class="ruby-keyword kw">end</span>
155
+ 39: <span class="ruby-keyword kw">end</span>
156
+ 40: <span class="ruby-keyword kw">end</span>
157
+ </pre>
158
+ </div>
159
+ </div>
160
+ </div>
161
+
162
+
163
+ </div>
164
+
165
+
166
+ </div>
167
+
168
+
169
+ <div id="validator-badges">
170
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
171
+ </div>
172
+
173
+ </body>
174
+ </html>
@@ -0,0 +1,165 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Mack::Routes::Urls</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Mack::Routes::Urls</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/mack-distributed/extensions/urls_rb.html">
59
+ lib/mack-distributed/extensions/urls.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000017">distributed_url</a>&nbsp;&nbsp;
84
+ </div>
85
+ </div>
86
+
87
+ </div>
88
+
89
+
90
+ <!-- if includes -->
91
+
92
+ <div id="section">
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <!-- if method_list -->
102
+ <div id="methods">
103
+ <h3 class="section-bar">Public Instance methods</h3>
104
+
105
+ <div id="method-M000017" class="method-detail">
106
+ <a name="M000017"></a>
107
+
108
+ <div class="method-heading">
109
+ <a href="#M000017" class="method-signature">
110
+ <span class="method-name">distributed_url</span><span class="method-args">(app_name, route_name, options = {})</span>
111
+ </a>
112
+ </div>
113
+
114
+ <div class="method-description">
115
+ <p>
116
+ Retrieves a distributed route from a DRb server.
117
+ </p>
118
+ <p>
119
+ Example:
120
+ </p>
121
+ <pre>
122
+ distributed_url(:app_1, :home_page_url)
123
+ distributed_url(:registration_app, :signup_url, {:from =&gt; :google})
124
+ </pre>
125
+ <p><a class="source-toggle" href="#"
126
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
127
+ <div class="method-source-code" id="M000017-source">
128
+ <pre>
129
+ <span class="ruby-comment cmt"># File lib/mack-distributed/extensions/urls.rb, line 11</span>
130
+ 11: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">distributed_url</span>(<span class="ruby-identifier">app_name</span>, <span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span> = {})
131
+ 12: <span class="ruby-identifier">route_name</span> = <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">to_s</span>
132
+ 13: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/_url$/</span>)
133
+ 14: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/_distributed_url$/</span>)
134
+ 15: <span class="ruby-identifier">route_name</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;_url&quot;</span>, <span class="ruby-value str">&quot;_distributed_url&quot;</span>)
135
+ 16: <span class="ruby-keyword kw">end</span>
136
+ 17: <span class="ruby-keyword kw">else</span>
137
+ 18: <span class="ruby-identifier">route_name</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;_distributed_url&quot;</span>
138
+ 19: <span class="ruby-keyword kw">end</span>
139
+ 20:
140
+ 21: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">app_config</span>.<span class="ruby-identifier">mack</span>.<span class="ruby-identifier">distributed_app_name</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">app_name</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">app_config</span>.<span class="ruby-identifier">mack</span>.<span class="ruby-identifier">distributed_app_name</span>.<span class="ruby-identifier">to_sym</span>
141
+ 22: <span class="ruby-comment cmt"># if it's local let's just use it and not go out to Rinda</span>
142
+ 23: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span>)
143
+ 24: <span class="ruby-keyword kw">end</span>
144
+ 25: <span class="ruby-identifier">d_urls</span> = <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Distributed</span><span class="ruby-operator">::</span><span class="ruby-constant">Routes</span><span class="ruby-operator">::</span><span class="ruby-constant">Urls</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">app_name</span>)
145
+ 26: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Distributed</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">UnknownRouteName</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app_name</span>, <span class="ruby-identifier">route_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">d_urls</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">route_name</span>)
146
+ 27: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">d_urls</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">route_name</span>, <span class="ruby-identifier">options</span>)
147
+ 28: <span class="ruby-keyword kw">end</span>
148
+ </pre>
149
+ </div>
150
+ </div>
151
+ </div>
152
+
153
+
154
+ </div>
155
+
156
+
157
+ </div>
158
+
159
+
160
+ <div id="validator-badges">
161
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
162
+ </div>
163
+
164
+ </body>
165
+ </html>
@@ -0,0 +1 @@
1
+ Mon, 08 Sep 2008 10:57:23 -0400
@@ -0,0 +1,272 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Mon Sep 08 10:32:45 -0400 2008</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h3>Setup</h3>
73
+ <p>
74
+ Using distributed functionality with Mack is incredibly easy. The first
75
+ thing we need to do is start the Mack ring server.
76
+ </p>
77
+ <pre>
78
+ mack_ring_server start
79
+ </pre>
80
+ <p>
81
+ That&#8216;s the glue that holds everything together. The ring server acts
82
+ a registry/lookup agent so applications know where to find the services
83
+ they are looking for.
84
+ </p>
85
+ <p>
86
+ In order to use the distributed functionality, you really need two
87
+ applications. The first application will be serving the distributed
88
+ object(s), routes, etc&#8230; and the second application will be using the
89
+ distributed functionality. Both applications will need the mack-distributed
90
+ gem. In the config/initializers/gems.rb add the following to both
91
+ applications:
92
+ </p>
93
+ <pre>
94
+ gem.add &quot;mack-distributed&quot;, :libs =&gt; &quot;mack-distributed&quot;
95
+ </pre>
96
+ <h2>Using Distributed Objects (Models)</h2>
97
+ <p>
98
+ Distributed objects are an easy way to share functionality across many
99
+ different Mack applications. Whether it&#8216;s a database model, or a bit
100
+ of library code, it&#8216;s easy to share and re-use.
101
+ </p>
102
+ <h3>Application 1 (Server)</h3>
103
+ <p>
104
+ Let&#8216;s configure our &#8216;server&#8217; application. This is where
105
+ pretty much all the &#8216;heavy lifting&#8217; is done. First we need
106
+ setup our configuration file:
107
+ </p>
108
+ <p>
109
+ config/app_config/default.yml:
110
+ </p>
111
+ <pre>
112
+ # All distributed applications need to have a unique name so they can easily be identified for lookup.
113
+ mack::distributed_app_name: my_cool_app
114
+ # Turn object sharing on
115
+ mack::share_objects: true
116
+ </pre>
117
+ <p>
118
+ Let&#8216;s assume that we have a simple User DataMapper model that looks
119
+ something like this:
120
+ </p>
121
+ <pre>
122
+ class User
123
+ include DataMapper::Resource
124
+
125
+ property :id, Serial
126
+ property :username, String
127
+ end
128
+ </pre>
129
+ <p>
130
+ It takes only one line of code to make that into a distributed object. We
131
+ just need to include <a
132
+ href="../classes/Mack/Distributable.html">Mack::Distributable</a> into the
133
+ User class, like such:
134
+ </p>
135
+ <pre>
136
+ class User
137
+ include Mack::Distributable
138
+ include DataMapper::Resource
139
+
140
+ property :id, Serial
141
+ property :username, String
142
+ end
143
+ </pre>
144
+ <p>
145
+ Now, start your server:
146
+ </p>
147
+ <pre>
148
+ rake server
149
+ </pre>
150
+ <h3>Application 2 (Client)</h3>
151
+ <p>
152
+ Here&#8216;s where things get really cool. We don&#8216;t have to do
153
+ anything else to our second application to get it find and use our User
154
+ model from the first application. When we add the mack-distributed gem,
155
+ we&#8216;ve given it all the magic it needs to run.
156
+ </p>
157
+ <p>
158
+ Let&#8216;s start up our console:
159
+ </p>
160
+ <pre>
161
+ rake console
162
+ </pre>
163
+ <p>
164
+ Now, in our console we can do the following:
165
+ </p>
166
+ <pre>
167
+ user = Mack::Distributed::User.new
168
+ user.username = &quot;foobar&quot;
169
+ user.save
170
+ </pre>
171
+ <p>
172
+ In the first application you&#8216;ll see an insert into the users table in
173
+ the logs. If you look in the database, you&#8216;ll see that we&#8216;ve
174
+ successfully created a new user.
175
+ </p>
176
+ <h3>How does it work?</h3>
177
+ <p>
178
+ When you include <a
179
+ href="../classes/Mack/Distributable.html">Mack::Distributable</a> into a
180
+ class it registers a proxy of that class with ring server. When another
181
+ application makes a call to Mack::Distributed::&lt;class_name&gt; it looks
182
+ up and finds that class in the ring server and returns the proxy object to
183
+ you.
184
+ </p>
185
+ <h3>Using Distributed Views</h3>
186
+ <p>
187
+ With distributed views, you can easily share views and layouts among
188
+ different Mack Applications.
189
+ </p>
190
+ <h2>Application 1 (Server)</h2>
191
+ <p>
192
+ config/app_config/default.yml: mack::distributed_site_domain: <a
193
+ href="http://localhost:3001">localhost:3001</a> mack::distributed_app_name:
194
+ my_cool_app # Turn view sharing on mack::share_views: true # and all the
195
+ model sharing settings&#8230;
196
+ </p>
197
+ <p>
198
+ That&#8216;s it. When the server is started, the distributed view module
199
+ will register a proxy with rinda ready for use by the client.
200
+ </p>
201
+ <h2>Application 2 (Client)</h2>
202
+ <p>
203
+ To use distributed view, you need to specify a fully qualified distributed
204
+ URI in the form of:
205
+ </p>
206
+ <pre>
207
+ distributed://app_name/path
208
+ </pre>
209
+ <p>
210
+ so, let&#8216;s say I want to render a page using a layout in application
211
+ 1, I&#8216;d do:
212
+ </p>
213
+ <pre>
214
+ render(:action, &quot;index&quot;, :layout =&gt; &quot;distributed://my_cool_app/application&quot;)
215
+ </pre>
216
+ <p>
217
+ The above code will render the index page using application.html layout
218
+ that lives in the application 1 space.
219
+ </p>
220
+ <p>
221
+ You can also specify the distributed layout globally in the controller.
222
+ Example:
223
+ </p>
224
+ <pre>
225
+ class MyController
226
+ include Mack::Controller
227
+
228
+ layout &quot;distributed://my_cool_app/application&quot;
229
+ end
230
+ </pre>
231
+ <p>
232
+ All the actions in MyController will use the distributed layout
233
+ </p>
234
+ <p>
235
+ Now, to render a distributed view, you&#8216;d do the following:
236
+ </p>
237
+ <pre>
238
+ render(:distributed, &quot;distributed://my_cool_app/admin/index&quot;)
239
+ </pre>
240
+
241
+ </div>
242
+
243
+
244
+ </div>
245
+
246
+
247
+ </div>
248
+
249
+
250
+ <!-- if includes -->
251
+
252
+ <div id="section">
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <!-- if method_list -->
262
+
263
+
264
+ </div>
265
+
266
+
267
+ <div id="validator-badges">
268
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
269
+ </div>
270
+
271
+ </body>
272
+ </html>