riaction 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.yardoc/checksums +11 -0
  2. data/.yardoc/objects/root.dat +0 -0
  3. data/.yardoc/proxy_types +0 -0
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile.lock +12 -8
  6. data/README.md +6 -1
  7. data/db/riaction.db +0 -0
  8. data/doc/Riaction/ConfigurationError.html +116 -0
  9. data/doc/Riaction/Constants.html +389 -0
  10. data/doc/Riaction/CrudEventCallback.html +402 -0
  11. data/doc/Riaction/EventPerformer.html +250 -0
  12. data/doc/Riaction/NoEventDefined.html +116 -0
  13. data/doc/Riaction/NoProfileDefined.html +116 -0
  14. data/doc/Riaction/ProfileCreationCallback.html +192 -0
  15. data/doc/Riaction/ProfileCreator.html +235 -0
  16. data/doc/Riaction/Railtie.html +116 -0
  17. data/doc/Riaction/Riaction/ClassMethods.html +837 -0
  18. data/doc/Riaction/Riaction/Event/InstanceMethods.html +301 -0
  19. data/doc/Riaction/Riaction/Event.html +108 -0
  20. data/doc/Riaction/Riaction/InstanceMethods.html +198 -0
  21. data/doc/Riaction/Riaction/Profile/InstanceMethods.html +746 -0
  22. data/doc/Riaction/Riaction/Profile.html +108 -0
  23. data/doc/Riaction/Riaction.html +125 -0
  24. data/doc/Riaction/RuntimeError.html +116 -0
  25. data/doc/Riaction.html +124 -0
  26. data/doc/RiactionGenerator.html +188 -0
  27. data/doc/_index.html +263 -0
  28. data/doc/class_list.html +47 -0
  29. data/doc/css/common.css +1 -0
  30. data/doc/css/full_list.css +55 -0
  31. data/doc/css/style.css +322 -0
  32. data/doc/file.README.html +304 -0
  33. data/doc/file_list.html +49 -0
  34. data/doc/frames.html +13 -0
  35. data/doc/index.html +304 -0
  36. data/doc/js/app.js +205 -0
  37. data/doc/js/full_list.js +173 -0
  38. data/doc/js/jquery.js +16 -0
  39. data/doc/method_list.html +294 -0
  40. data/doc/top-level-namespace.html +107 -0
  41. data/lib/riaction/constants.rb +6 -2
  42. data/lib/riaction/crud_event_callback.rb +3 -0
  43. data/lib/riaction/event_performer.rb +10 -5
  44. data/lib/riaction/profile_creation_callback.rb +2 -0
  45. data/lib/riaction/riaction.rb +11 -7
  46. data/lib/riaction/version.rb +1 -1
  47. data/lib/tasks/riaction.rake +25 -22
  48. data/riaction.gemspec +4 -2
  49. data/spec/event_performer_spec.rb +23 -0
  50. data/spec/riaction_spec.rb +33 -4
  51. metadata +79 -19
@@ -0,0 +1,304 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="_index.html" title="Index">Index</a> &raquo;
37
+ <span class="title">File: README</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a id="class_list_link" href="#">Class List</a>
46
+
47
+ <a id="method_list_link" href="#">Method List</a>
48
+
49
+ <a id="file_list_link" href="#">File List</a>
50
+
51
+ </div>
52
+ <div class="clear"></div>
53
+ </div>
54
+
55
+ <iframe id="search_frame"></iframe>
56
+
57
+ <div id="content"><div id='filecontents'><h1>Overview</h1>
58
+
59
+ <p>You&#39;ve <a href="http://en.wikipedia.org/wiki/Gamification">gamified</a> your Rails app using IActionable&#39;s services, or maybe you&#39;re thinking about it. IActionable offers a restful API to log events from your game; these events (&quot;sign in&quot;, &quot;write a review&quot;, etc) earn points, achievements and more for the users that perform them. This gem provides a way to tie these events to the CRUD actions of the ActiveRecord models that make up your restful Rails app. Through an &quot;acts-as&quot; style mix-in, riaction takes the &quot;write a review&quot; event defined in your IActionable game, and drives it with the actual creation of a review object. Riaction makes use of the <a href="https://github.com/zortnac/Ruby-IActionable">Ruby-IActionable gem</a> to connect to the IActionable API.</p>
60
+
61
+ <h1>How To Use</h1>
62
+
63
+ <h2>Installation</h2>
64
+
65
+ <pre class="code ruby"><code><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_riaction'>riaction</span>
66
+ </code></pre>
67
+
68
+ <h2>Requirements and Dependencies</h2>
69
+
70
+ <p>Riaction uses <a href="https://github.com/defunkt/resque">Resque</a> to schedule and perform all requests to IActionable.</p>
71
+
72
+ <h3>Generators</h3>
73
+
74
+ <p>Riaction comes with a generator for creating a YAML file to contain your credentials for each environment of your application. The YAML file is necessary for riaction to run correctly in your rails app.</p>
75
+
76
+ <pre class="code ruby"><code>rails g riaction development:12345:abcde production:54321:edcba
77
+ </code></pre>
78
+
79
+ <h3>Declaring A Model As A Profile</h3>
80
+
81
+ <p>In IActionable&#39;s API, events are explicitly tied to the user that generated them; an event cannot exist or be logged that doesn&#39;t belong to a user. In order to log an event for writing a review, we need to decide which model in our application will behave as the &quot;profile&quot; in IActionable&#39;s system. Here our user model will serve that purpose:</p>
82
+
83
+ <pre class="code ruby"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span>
84
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:profile</span><span class='comma'>,</span> <span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='symbol'>:player</span><span class='comma'>,</span> <span class='symbol'>:custom</span> <span class='op'>=&gt;</span> <span class='symbol'>:id</span>
85
+ <span class='kw'>end</span>
86
+
87
+ <span class='comment'># == Schema Information
88
+ </span><span class='comment'>#
89
+ </span><span class='comment'># Table name: users
90
+ </span><span class='comment'>#
91
+ </span><span class='comment'># id :integer(4)
92
+ </span><span class='comment'># nickname :string(255)
93
+ </span></code></pre>
94
+
95
+ <p>In the above example, the class User declares itself as a profile of type &quot;player&quot;. Profile types are defined on IActionable&#39;s account dashboard. Profiles are identifiable by a number of supported identifier types, and in the above example we&#39;ll be relying on the &quot;custom&quot; identifier type, which will point to the value of the model&#39;s unique key in the database. In other words, the user in our Rails app with an id of 7 will map to a profile on IActionable of type &quot;player&quot;, and a &quot;custom&quot; identifier with a value of &quot;7.&quot;</p>
96
+
97
+ <p>By declaring our user class as a riaction profile, an after-create callback will be registered on the class to create the corresponding profile on IActionable.</p>
98
+
99
+ <p>IActionable&#39;s profiles also have a &quot;display name&quot; property which can also be given here, and which should be a method that the object responds to:</p>
100
+
101
+ <pre class="code ruby"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span>
102
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:profile</span><span class='comma'>,</span> <span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='symbol'>:player</span><span class='comma'>,</span> <span class='symbol'>:custom</span> <span class='op'>=&gt;</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='symbol'>:display_name</span> <span class='op'>=&gt;</span> <span class='symbol'>:nickname</span>
103
+ <span class='kw'>end</span>
104
+ </code></pre>
105
+
106
+ <h4>Profile Instance Methods</h4>
107
+
108
+ <p>Classes that declare themselves as riaction profiles are given instance methods that hit various points in the IActionable API for loading a profile&#39;s data from the game, using the <a href="https://github.com/zortnac/Ruby-IActionable">Ruby-IActionable gem</a>.</p>
109
+
110
+ <pre class="code ruby"><code><span class='ivar'>@user_instance</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
111
+
112
+ <span class='comment'># return the user's profile summary and (up to) 10 of their recent achievements
113
+ </span><span class='ivar'>@user_instance</span><span class='period'>.</span><span class='id identifier rubyid_riaction_profile_summary'>riaction_profile_summary</span><span class='lparen'>(</span><span class='int'>10</span><span class='rparen'>)</span>
114
+
115
+ <span class='comment'># return the user's summary of challenges, limited to the ones already completed
116
+ </span><span class='ivar'>@user_instance</span><span class='period'>.</span><span class='id identifier rubyid_riaction_profile_challenges'>riaction_profile_challenges</span><span class='lparen'>(</span><span class='symbol'>:completed</span><span class='rparen'>)</span>
117
+ </code></pre>
118
+
119
+ <h4>Multiple Profile Types</h4>
120
+
121
+ <p>Riaction will support a model in your app to map to multiple profiles defined in IActionable, if your situation calls for that:</p>
122
+
123
+ <pre class="code ruby"><code><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span>
124
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:profile</span><span class='comma'>,</span> <span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='symbol'>:light_world_player</span><span class='comma'>,</span> <span class='symbol'>:custom</span> <span class='op'>=&gt;</span> <span class='symbol'>:id</span>
125
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:profile</span><span class='comma'>,</span> <span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='symbol'>:dark_world_player</span><span class='comma'>,</span> <span class='symbol'>:custom</span> <span class='op'>=&gt;</span> <span class='symbol'>:id</span>
126
+ <span class='kw'>end</span>
127
+
128
+ <span class='comment'># == Schema Information
129
+ </span><span class='comment'>#
130
+ </span><span class='comment'># Table name: users
131
+ </span><span class='comment'>#
132
+ </span><span class='comment'># id :integer(4)
133
+ </span><span class='comment'># nickname :string(255)
134
+ </span></code></pre>
135
+
136
+ <p>In the above example we want to define our user model as two types of players in our (apparently Zelda-inspired) game. The model will behave exactly as it would with only a single profile declared, and the first one declared ( <code>:light_world_player</code> ) will always be the default used, unless a different profile type is set explicitly:</p>
137
+
138
+ <pre class="code ruby"><code><span class='ivar'>@user_instance</span><span class='period'>.</span><span class='id identifier rubyid_riaction_set_profile'>riaction_set_profile</span><span class='lparen'>(</span><span class='symbol'>:dark_world_player</span><span class='rparen'>)</span>
139
+ </code></pre>
140
+
141
+ <p>Setting the profile type only affects the instance it is called on, and the change will persist for the life of the object or until changed again.</p>
142
+
143
+ <h3>Declaring Events</h3>
144
+
145
+ <p>Models in your application may declare any number of events that they wish to log through IActionable. Just as an event on IActionable must belong to a profile, in this example the model generating the event belongs to the model that behaves as a profile:</p>
146
+
147
+ <pre class="code ruby"><code><span class='kw'>class</span> <span class='const'>Review</span>
148
+ <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:user</span>
149
+
150
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span>
151
+
152
+ <span class='kw'>def</span> <span class='id identifier rubyid_length'>length</span>
153
+ <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
154
+ <span class='kw'>end</span>
155
+
156
+ <span class='kw'>def</span> <span class='id identifier rubyid_stats'>stats</span>
157
+ <span class='lbrace'>{</span>
158
+ <span class='symbol'>:length</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='comma'>,</span>
159
+ <span class='symbol'>:rating</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_stars'>stars</span>
160
+ <span class='rbrace'>}</span>
161
+ <span class='kw'>end</span>
162
+ <span class='kw'>end</span>
163
+
164
+ <span class='comment'># == Schema Information
165
+ </span><span class='comment'>#
166
+ </span><span class='comment'># Table name: comments
167
+ </span><span class='comment'>#
168
+ </span><span class='comment'># id :integer(4)
169
+ </span><span class='comment'># user_id :integer(4)
170
+ </span><span class='comment'># stars :integer(4)
171
+ </span><span class='comment'># text :string(255)
172
+ </span></code></pre>
173
+
174
+ <p>In the above example: </p>
175
+
176
+ <ul>
177
+ <li><code>:write_a_review</code> is the name of the event and should match the key used on IActionable.<br></li>
178
+ <li>The value for <code>:trigger</code> determines the action that will cause the event to fire, and can also be <code>:update</code> or <code>:destroy</code>, and will automatically fire when a record is created, updated, or destroyed, respectively.</li>
179
+ <li><strong>If the value for <code>:trigger</code> is not given, <code>:create</code> will be assumed.</strong></li>
180
+ <li>The value given to <code>:profile</code> should return the riaction profile object that this event will be logged under.</li>
181
+ </ul>
182
+
183
+ <!-- end list -->
184
+
185
+ <h4>Event Parameters</h4>
186
+
187
+ <p>Part of the power in the way IActionable may be configured to process your events is in the key-value parameters you can send along with the event itself. Riaction allows you to define an event with these parameters. Parameters may be a hash with static values:</p>
188
+
189
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:foo</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bar</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span>
190
+ </code></pre>
191
+
192
+ <p>...a hash where some values reference methods:</p>
193
+
194
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:review_length</span> <span class='op'>=&gt;</span> <span class='symbol'>:length</span><span class='rbrace'>}</span>
195
+ </code></pre>
196
+
197
+ <p>...a proc:</p>
198
+
199
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=&gt;</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='op'>|</span> <span class='lbrace'>{</span><span class='symbol'>:length</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rbrace'>}</span><span class='rbrace'>}</span>
200
+ </code></pre>
201
+
202
+ <p>...or the name of an instance method (which ought to return a hash):</p>
203
+
204
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:params</span> <span class='op'>=&gt;</span> <span class='symbol'>:stats</span>
205
+ </code></pre>
206
+
207
+ <h4>Conditional Events</h4>
208
+
209
+ <p>The logging of an event may be conditional:</p>
210
+
211
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:if</span> <span class='op'>=&gt;</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stars'>stars</span> <span class='op'>&gt;</span> <span class='int'>3</span><span class='rbrace'>}</span>
212
+ </code></pre>
213
+
214
+ <p>...where the value of <code>:if</code> may be an instance method or a proc.</p>
215
+
216
+ <h3>Things To Note</h3>
217
+
218
+ <h4>Non-CRUD Actions</h4>
219
+
220
+ <p>Sometimes when create, update, and destroy just don&#39;t really make sense for the event, custom triggers may be declared:</p>
221
+
222
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:receive_thumbs_up</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:thumbs_up</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span>
223
+ </code></pre>
224
+
225
+ <p>In the above example, in order to have the review fire an event when it gets a thumbs up from another user, we declare a trigger called <code>:thumbs_up</code>. Since this won&#39;t be fired automatically like a CRUD action, an instance method will be provided to fire it by hand:</p>
226
+
227
+ <pre class="code ruby"><code><span class='ivar'>@review_instance</span><span class='period'>.</span><span class='id identifier rubyid_trigger_thumbs_up!'>trigger_thumbs_up!</span>
228
+ </code></pre>
229
+
230
+ <h4>Events and Multiple Profile Types</h4>
231
+
232
+ <p>If the object given as the riaction profile for an event defines more than one profile type, the default profile type (the first one declared in the class) will be used. To use a different one, pass in the name of the alternate type:</p>
233
+
234
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:write_a_review</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='symbol'>:profile_type</span> <span class='op'>=&gt;</span> <span class='symbol'>:dark_world_player</span>
235
+ </code></pre>
236
+
237
+ <h4>Profiles With Their Own Events</h4>
238
+
239
+ <p>A class that declares itself as a profile may also declare events, and for those events it may point to itself as the profile to use:</p>
240
+
241
+ <pre class="code ruby"><code><span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:profile</span><span class='comma'>,</span> <span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='symbol'>:player</span><span class='comma'>,</span> <span class='symbol'>:custom</span> <span class='op'>=&gt;</span> <span class='symbol'>:id</span>
242
+ <span class='id identifier rubyid_riaction'>riaction</span> <span class='symbol'>:event</span><span class='comma'>,</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='symbol'>:join_the_game</span><span class='comma'>,</span> <span class='symbol'>:trigger</span> <span class='op'>=&gt;</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='symbol'>:profile</span> <span class='op'>=&gt;</span> <span class='symbol'>:self</span>
243
+ </code></pre>
244
+
245
+ <p>In the above example of a declaration on the User class, the user will fire a <code>:join_the_game</code> event using itself as the profile upon its creation. <em>The profile declaration must come before the event declaration.</em></p>
246
+
247
+ <h4>Turning Riaction Off</h4>
248
+
249
+ <p>If you want to avoid the automatic creation of a profile, or the automatic logging of an event, classes that declare themselves as riaction profiles or event drivers provide a method to disable those automatic events:</p>
250
+
251
+ <pre class="code ruby"><code><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_riactionless'>riactionless</span><span class='lbrace'>{</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='symbol'>:nickname</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>zortnac</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='comment'># won't create the profile for the newly created user
252
+ </span><span class='const'>Review</span><span class='period'>.</span><span class='id identifier rubyid_riactionless'>riactionless</span><span class='lbrace'>{</span> <span class='ivar'>@user_instance</span><span class='period'>.</span><span class='id identifier rubyid_reviews'>reviews</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='symbol'>:text</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>loved it!</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='comment'># won't fire the 'write_a_review' event
253
+ </span><span class='const'>Review</span><span class='period'>.</span><span class='id identifier rubyid_riactionless'>riactionless</span><span class='lbrace'>{</span> <span class='ivar'>@review_instance</span><span class='period'>.</span><span class='id identifier rubyid_trigger_thumbs_up!'>trigger_thumbs_up!</span> <span class='rbrace'>}</span> <span class='comment'># won't fire the 'receive_thumbs_up' event
254
+ </span></code></pre>
255
+
256
+ <h3>Rails Rake Tasks</h3>
257
+
258
+ <p>There are 3 rake tasks included for summarizing all of your models&#39; declarations as well as a way to initialize profiles on IActionable. To see a report of all the events declared across your application, run the following:</p>
259
+
260
+ <pre class="code ruby"><code>rake riaction:rails:list:events
261
+ </code></pre>
262
+
263
+ <p>To see a report of all the profiles declared across your application, run the following:</p>
264
+
265
+ <pre class="code ruby"><code>rake riaction:rails:list:profiles
266
+ </code></pre>
267
+
268
+ <p>To process all of the models in your application that declare themselves as profiles and initialize them on IActionable (for instance if you&#39;ve added IActionable to an existing application with an established user base), run the following:</p>
269
+
270
+ <pre class="code ruby"><code>rake riaction:rails:process:profiles
271
+ </code></pre>
272
+
273
+ <p>To run a specific event on all instances off a class that define that event:</p>
274
+
275
+ <pre class="code ruby"><code>rake riaction:rails:process:event['ClassName', :event_name]
276
+ </code></pre>
277
+
278
+ <hr>
279
+
280
+ <h2>IActionable</h2>
281
+
282
+ <p><a href="http://www.iactionable.com">Visit their website!</a></p>
283
+
284
+ <h2>Tested Ruby Versions</h2>
285
+
286
+ <p>riaction has been tested on major releases of ruby 1.9.2 and ruby 1.9.3-p125. If you find something please file a bug <a href="https://github.com/zortnac/riaction/issues">https://github.com/zortnac/riaction/issues</a></p>
287
+
288
+ <h2>Authors</h2>
289
+
290
+ <p>Christopher Eberz; <a href="mailto:chris@chriseberz.com">chris@chriseberz.com</a>; @zortnac</p>
291
+
292
+ <p>Katie Miller; <a href="mailto:kmiller@elctech.com">kmiller@elctech.com</a></p>
293
+
294
+ <p>Nicholas Audo; <a href="mailto:naudo@naudo.de">naudo@naudo.de</a>; @naudo</p>
295
+ </div></div>
296
+
297
+ <div id="footer">
298
+ Generated on Tue Mar 6 22:00:20 2012 by
299
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
300
+ 0.7.5 (ruby-1.9.3).
301
+ </div>
302
+
303
+ </body>
304
+ </html>
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <base id="base_target" target="_parent" />
19
+ </head>
20
+ <body>
21
+ <script type="text/javascript" charset="utf-8">
22
+ if (window.top.frames.main) {
23
+ document.getElementById('base_target').target = 'main';
24
+ document.body.className = 'frames';
25
+ }
26
+ </script>
27
+ <div id="content">
28
+ <h1 id="full_list_header">File List</h1>
29
+ <div id="nav">
30
+
31
+ <a target="_self" href="class_list.html">Classes</a>
32
+
33
+ <a target="_self" href="method_list.html">Methods</a>
34
+
35
+ <a target="_self" href="file_list.html">Files</a>
36
+
37
+ </div>
38
+ <div id="search">Search: <input type="text" /></div>
39
+
40
+ <ul id="full_list" class="files">
41
+
42
+
43
+ <li class="r1"><a href="index.html" title="README">README</a></li>
44
+
45
+
46
+ </ul>
47
+ </div>
48
+ </body>
49
+ </html>
data/doc/frames.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>Documentation by YARD 0.7.5</title>
8
+ </head>
9
+ <frameset cols="20%,*">
10
+ <frame name="list" src="class_list.html" />
11
+ <frame name="main" src="index.html" />
12
+ </frameset>
13
+ </html>