docs/LoggableActivity/Activity.html in loggable_activity-0.1.56 vs docs/LoggableActivity/Activity.html in loggable_activity-0.1.58
- old
+ new
@@ -73,25 +73,21 @@
<ul class="link-list" role="directory">
<li ><a href="#method-c-activities_for_actor">::activities_for_actor</a>
<li ><a href="#method-c-last">::last</a>
<li ><a href="#method-c-latest">::latest</a>
+ <li ><a href="#method-i-actor_deleted-3F">#actor_deleted?</a>
<li ><a href="#method-i-actor_display_name">#actor_display_name</a>
- <li ><a href="#method-i-actor_key">#actor_key</a>
+ <li ><a href="#method-i-actor_secret_key">#actor_secret_key</a>
<li ><a href="#method-i-attrs">#attrs</a>
<li ><a href="#method-i-must_have_at_least_one_payload">#must_have_at_least_one_payload</a>
<li ><a href="#method-i-ordered_payloads">#ordered_payloads</a>
- <li ><a href="#method-i-path">#path</a>
- <li ><a href="#method-i-previous_associations_attrs">#previous_associations_attrs</a>
+ <li ><a href="#method-i-payloads_attrs">#payloads_attrs</a>
<li ><a href="#method-i-primary_payload">#primary_payload</a>
- <li ><a href="#method-i-primary_payload_attrs">#primary_payload_attrs</a>
+ <li ><a href="#method-i-primary_route">#primary_route</a>
<li ><a href="#method-i-record_display_name">#record_display_name</a>
<li ><a href="#method-i-record_key">#record_key</a>
- <li ><a href="#method-i-relations_attrs">#relations_attrs</a>
- <li ><a href="#method-i-update_activity_attrs">#update_activity_attrs</a>
- <li ><a href="#method-i-update_attrs">#update_attrs</a>
- <li ><a href="#method-i-updated_relations_attrs">#updated_relations_attrs</a>
</ul>
</div>
</div>
</nav>
@@ -129,13 +125,13 @@
<div class="method-description">
<p>Returns a list of activities for a given actor.</p>
<div class="method-source-code" id="activities_for_actor-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 155</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 124</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">activities_for_actor</span>(<span class="ruby-identifier">actor</span>, <span class="ruby-identifier">limit</span> = <span class="ruby-value">20</span>, <span class="ruby-identifier">params</span> = { <span class="ruby-value">offset:</span> <span class="ruby-value">0</span> })
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>.<span class="ruby-identifier">latest</span>(<span class="ruby-identifier">limit</span>, <span class="ruby-identifier">params</span>).<span class="ruby-identifier">where</span>(<span class="ruby-value">actor:</span>)
+ <span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>.<span class="ruby-identifier">latest</span>(<span class="ruby-identifier">limit</span>, <span class="ruby-identifier">params</span>).<span class="ruby-identifier">where</span>(<span class="ruby-value">actor:</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -149,14 +145,14 @@
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns the last activity.</p>
+ <p>Returns the last activity. This is done to support of UUID primary keys.</p>
<div class="method-source-code" id="last-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 171</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 142</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">last</span>(<span class="ruby-identifier">limit</span> = <span class="ruby-value">1</span>)
<span class="ruby-keyword">return</span> <span class="ruby-identifier">latest</span>(<span class="ruby-value">1</span>).<span class="ruby-identifier">first</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
<span class="ruby-identifier">latest</span>(<span class="ruby-identifier">limit</span>)
<span class="ruby-keyword">end</span></pre>
@@ -174,20 +170,20 @@
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns a list of activities ordered by creation date.</p>
+ <p>Returns a list of activities ordered by creation date. This is done to support UUID primary keys.</p>
<div class="method-source-code" id="latest-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 160</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 130</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">latest</span>(<span class="ruby-identifier">limit</span> = <span class="ruby-value">20</span>, <span class="ruby-identifier">params</span> = { <span class="ruby-value">offset:</span> <span class="ruby-value">0</span> })
<span class="ruby-identifier">offset</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:offset</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>
+ <span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Activity</span>
.<span class="ruby-identifier">all</span>
.<span class="ruby-identifier">order</span>(<span class="ruby-value">created_at:</span> <span class="ruby-value">:desc</span>)
- .<span class="ruby-identifier">includes</span>(<span class="ruby-value">:payloads</span>)
+ .<span class="ruby-identifier">includes</span>(<span class="ruby-value">payloads:</span> <span class="ruby-value">:encryption_key</span>)
.<span class="ruby-identifier">offset</span>(<span class="ruby-identifier">offset</span>)
.<span class="ruby-identifier">limit</span>(<span class="ruby-identifier">limit</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -223,15 +219,15 @@
<pre class="ruby"><span class="ruby-string">"Elvis Presley"</span>
</pre>
<div class="method-source-code" id="actor_display_name-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 148</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 117</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_display_name</span>
- <span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">encrypted_actor_display_name</span>.<span class="ruby-identifier">nil?</span>
+ <span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">actor_deleted?</span>
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-identifier">encrypted_actor_display_name</span>, <span class="ruby-identifier">actor_key</span>)
+ <span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-identifier">encrypted_actor_name</span>, <span class="ruby-identifier">actor_secret_key</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -251,11 +247,11 @@
<p>Each hash in the array contains:</p>
<ul><li>
<p>:record_type: The class name of the record.</p>
</li><li>
-<p>:payload_type: A descriptor of the payload’s role (e.g., ‘primary_payload’ or ‘current_association’).</p>
+<p>:related_to_activity_as: A descriptor of the payload’s role (e.g., ‘primary_payload’ or ‘current_association’).</p>
</li><li>
<p>:attrs: A hash of the record’s attributes.</p>
</li></ul>
<p>Example usage:</p>
@@ -264,92 +260,93 @@
</pre>
<p>Sample return value:</p>
<pre>[
- { record_type: MODEL_NAME, payload_type: "primary_payload", attrs: { "KEY" => "VALUE", ... } },
- { record_type: MODEL_NAME, payload_type: "current_association", attrs: { "KEY" => "VALUE", ... } },
+ { record_type: MODEL_NAME, related_to_activity_as: "primary_payload", attrs: { "KEY" => "VALUE", ... } },
+ { record_type: MODEL_NAME, related_to_activity_as: "current_association", attrs: { "KEY" => "VALUE", ... } },
...
]</pre>
<div class="method-source-code" id="attrs-source">
<pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 37</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">attrs</span>
- <span class="ruby-identifier">ordered_payloads</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">payload</span><span class="ruby-operator">|</span>
- {
- <span class="ruby-value">record_type:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_type</span>,
- <span class="ruby-value">record_id:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_id</span>,
- <span class="ruby-value">payload_type:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">payload_type</span>,
- <span class="ruby-value">attrs:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">attrs</span>,
- <span class="ruby-value">path:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">payload_route</span>
- }
- <span class="ruby-keyword">end</span>
+ {
+ <span class="ruby-value">actor_type:</span>,
+ <span class="ruby-value">actor_id:</span>,
+ <span class="ruby-value">action:</span>,
+ <span class="ruby-value">actor_display_name:</span>,
+ <span class="ruby-value">record_display_name:</span>,
+ <span class="ruby-value">payloads:</span> <span class="ruby-identifier">payloads_attrs</span>
+ }
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
- <div id="method-i-path" class="method-detail ">
+ <div id="method-i-payloads_attrs" class="method-detail ">
<div class="method-header">
<div class="method-heading">
- <span class="method-name">path</span><span
+ <span class="method-name">payloads_attrs</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns the path for the activity.</p>
+
-<p>Example:</p>
-
-<pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">path</span>
-</pre>
-
-<p>Returns:</p>
-
-<pre class="ruby"><span class="ruby-string">"/path/to/activity"</span>
-</pre>
-
- <div class="method-source-code" id="path-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 135</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path</span>
- <span class="ruby-identifier">primary_payload</span>&.<span class="ruby-identifier">route</span>
+ <div class="method-source-code" id="payloads_attrs-source">
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 48</span>
+<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">payloads_attrs</span>
+ <span class="ruby-identifier">ordered_payloads</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">payload</span><span class="ruby-operator">|</span>
+ {
+ <span class="ruby-value">related_to_activity_as:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">related_to_activity_as</span>,
+ <span class="ruby-value">record_type:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_type</span>,
+ <span class="ruby-value">record_id:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">deleted?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_id</span>,
+ <span class="ruby-value">attrs:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">attrs</span>,
+ <span class="ruby-value">route:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">payload_route</span>,
+ <span class="ruby-value">record_display_name:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_display_name</span>,
+ <span class="ruby-value">current_payload:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">current_payload</span>,
+ <span class="ruby-value">data_owner:</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">data_owner</span>
+ }
+ <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
- <div id="method-i-primary_payload_attrs" class="method-detail ">
+ <div id="method-i-primary_route" class="method-detail ">
<div class="method-header">
<div class="method-heading">
- <span class="method-name">primary_payload_attrs</span><span
+ <span class="method-name">primary_route</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns the attributes for the primary payload, without the relations.</p>
+ <p>Returns the path for the activity.</p>
<p>Example:</p>
-<pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">primary_payload_attrs</span>
+<pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">path</span>
</pre>
<p>Returns:</p>
-<pre>{ "KEY_A" => "VALUE_A", "KEY_B" => "VALUE_B", ... }</pre>
+<pre class="ruby"><span class="ruby-string">"/path/to/activity"</span>
+</pre>
- <div class="method-source-code" id="primary_payload_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 88</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">primary_payload_attrs</span>
- <span class="ruby-identifier">primary_payload</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">primary_payload</span>.<span class="ruby-identifier">attrs</span> <span class="ruby-operator">:</span> {}
+ <div class="method-source-code" id="primary_route-source">
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 104</span>
+<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">primary_route</span>
+ <span class="ruby-identifier">primary_payload</span>.<span class="ruby-identifier">payload_route</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -376,140 +373,67 @@
<pre class="ruby"><span class="ruby-string">"David Bowie"</span>
</pre>
<div class="method-source-code" id="record_display_name-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 120</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 91</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record_display_name</span>
- <span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">encrypted_record_display_name</span>.<span class="ruby-identifier">nil?</span>
-
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-identifier">encrypted_record_display_name</span>, <span class="ruby-identifier">record_key</span>)
+ <span class="ruby-identifier">primary_payload</span>.<span class="ruby-identifier">record_display_name</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
- <div id="method-i-relations_attrs" class="method-detail ">
- <div class="method-header">
- <div class="method-heading">
- <span class="method-name">relations_attrs</span><span
- class="method-args">()</span>
- <span class="method-click-advice">click to toggle source</span>
- </div>
- </div>
+ </section>
- <div class="method-description">
- <p>Returns the attributes for the relations.</p>
+ <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
+ <header>
+ <h3>Private Instance Methods</h3>
+ </header>
-<p>Example:</p>
-
-<pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">relations_attrs</span>
-</pre>
-
-<p>Returns:</p>
-
-<pre>[
- {
- record_type: CLASS.NAME,
- record_id: INTEGER,
- payload_type: ENUM
- attrs: { "KEY_A" => "VALUE_A", "KEY_B" => "VALUE_B", ... }
- }
-]</pre>
-
- <div class="method-source-code" id="relations_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 107</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">relations_attrs</span>
- <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">filter</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">'current_association'</span> }
-<span class="ruby-keyword">end</span></pre>
- </div>
- </div>
-
-
- </div>
-
- <div id="method-i-update_activity_attrs" class="method-detail ">
+ <div id="method-i-actor_deleted-3F" class="method-detail ">
<div class="method-header">
<div class="method-heading">
- <span class="method-name">update_activity_attrs</span><span
+ <span class="method-name">actor_deleted?</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns a hash describing the attributes of an update activity, including updated attributes for a record and any updated related attributes.</p>
+ <p>Check if the actor is deleted. If the actor is deleted, it will return true. This way we don’t rely on access to the main DB to check if the actor is deleted.</p>
-<p>Example:</p>
-
-<pre class="ruby"><span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">update_activity_attrs</span>
-</pre>
-
-<p>The return value is structured as follows:</p>
-<ul><li>
-<p>:update_attrs contains the attributes of the record being updated, detailing changes from previous to new values.</p>
-</li><li>
-<p>:updated_relations_attrs is an array of hashes, each representing an updated related record. Each hash details the previous and current attributes of the relation.</p>
-</li></ul>
-
-<p>Example Return Structure:</p>
-
-<pre>{
- update_attrs: {
- record_class: "CLASS.NAME",
- attrs: [{ "KEY" => { from: "OLD_VALUE", to: "NEW_VALUE" } }]
- },
- updated_relations_attrs: [
- {
- record_class: "CLASS.NAME",
- previous_attrs: { attrs: { "KEY" => "VALUE", ... } },
- current_attrs: { attrs: { "KEY" => "VALUE", ... } }
- }
- ]
-}</pre>
-
- <div class="method-source-code" id="update_activity_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 72</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update_activity_attrs</span>
- {
- <span class="ruby-value">update_attrs:</span>,
- <span class="ruby-value">updated_relations_attrs:</span>
- }
+ <div class="method-source-code" id="actor_deleted-3F-source">
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 177</span>
+<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_deleted?</span>
+ <span class="ruby-identifier">actor_secret_key</span>.<span class="ruby-identifier">nil?</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
- </section>
-
- <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
- <header>
- <h3>Private Instance Methods</h3>
- </header>
-
- <div id="method-i-actor_key" class="method-detail ">
+ <div id="method-i-actor_secret_key" class="method-detail ">
<div class="method-header">
<div class="method-heading">
- <span class="method-name">actor_key</span><span
+ <span class="method-name">actor_secret_key</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
<p>Returns the key for the actor.</p>
- <div class="method-source-code" id="actor_key-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 224</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_key</span>
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">actor</span>.<span class="ruby-identifier">nil?</span>
-
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">EncryptionKey</span>.<span class="ruby-identifier">for_record</span>(<span class="ruby-identifier">actor</span>)&.<span class="ruby-identifier">key</span>
+ <div class="method-source-code" id="actor_secret_key-source">
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 182</span>
+<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">actor_secret_key</span>
+ <span class="ruby-comment"># @actor_key_secret_key ||=</span>
+ <span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">EncryptionKey</span>.<span class="ruby-identifier">for_record_by_type_and_id</span>(<span class="ruby-identifier">actor_type</span>, <span class="ruby-identifier">actor_id</span>)&.<span class="ruby-identifier">secret_key</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -526,11 +450,11 @@
<div class="method-description">
<p>Validates that the activity has at least one payload.</p>
<div class="method-source-code" id="must_have_at_least_one_payload-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 231</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 188</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">must_have_at_least_one_payload</span>
<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">:payloads</span>, <span class="ruby-string">'must have at least one payload'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -546,62 +470,47 @@
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns payloads sorted by :payload_type.</p>
+ <p>Returns payloads sorted by :related_to_activity_as.</p>
<div class="method-source-code" id="ordered_payloads-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 212</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 162</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ordered_payloads</span>
- <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">order</span>(<span class="ruby-value">:payload_type</span>)
+ <span class="ruby-comment"># payloads.order(related_to_activity_as: :desc)</span>
+ <span class="ruby-identifier">payloads</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
- <div id="method-i-previous_associations_attrs" class="method-detail ">
- <div class="method-header">
- <div class="method-heading">
- <span class="method-name">previous_associations_attrs</span><span
- class="method-args">()</span>
- <span class="method-click-advice">click to toggle source</span>
- </div>
- </div>
-
- <div class="method-description">
- <p>Returns the previous association attributes.</p>
-
- <div class="method-source-code" id="previous_associations_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 207</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">previous_associations_attrs</span>
- <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">'previous_association'</span> }
-<span class="ruby-keyword">end</span></pre>
- </div>
- </div>
-
-
- </div>
-
<div id="method-i-primary_payload" class="method-detail ">
<div class="method-header">
<div class="method-heading">
<span class="method-name">primary_payload</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
</div>
<div class="method-description">
- <p>Returns the primary payload.</p>
+ <p>Returns the primary payload associated with the activity.</p>
+<p>Example usage:</p>
+
+<pre class="ruby"><span class="ruby-identifier">payload</span> = <span class="ruby-ivar">@activity</span>.<span class="ruby-identifier">primary_payload</span>
+<span class="ruby-identifier">payload</span>.<span class="ruby-identifier">record_type</span> <span class="ruby-comment"># => 'SOMD_MODEL_NAME'</span>
+</pre>
+
<div class="method-source-code" id="primary_payload-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 189</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 156</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">primary_payload</span>
- <span class="ruby-identifier">ordered_payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">payload_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">'primary_payload'</span> }
+ <span class="ruby-identifier">related_to_activity_as</span> = <span class="ruby-node">%w[primary_payload primary_update_payload primary_destroy_payload]</span>
+ <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">related_to_activity_as</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">p</span>.<span class="ruby-identifier">related_to_activity_as</span>) }
<span class="ruby-keyword">end</span></pre>
</div>
</div>
@@ -618,72 +527,14 @@
<div class="method-description">
<p>Returns the key for the logged record.</p>
<div class="method-source-code" id="record_key-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 217</span>
+ <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 168</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record_key</span>
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">record</span>.<span class="ruby-identifier">nil?</span>
- <span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">EncryptionKey</span>.<span class="ruby-identifier">for_record</span>(<span class="ruby-identifier">record</span>)&.<span class="ruby-identifier">key</span>
-<span class="ruby-keyword">end</span></pre>
- </div>
- </div>
-
-
- </div>
-
- <div id="method-i-update_attrs" class="method-detail ">
- <div class="method-header">
- <div class="method-heading">
- <span class="method-name">update_attrs</span><span
- class="method-args">()</span>
- <span class="method-click-advice">click to toggle source</span>
- </div>
- </div>
-
- <div class="method-description">
- <p>Returns the attributes for the update+payload.</p>
-
- <div class="method-source-code" id="update_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 180</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update_attrs</span>
- <span class="ruby-identifier">update_payload_attrs</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">'update_payload'</span> }
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">update_payload_attrs</span>
-
- <span class="ruby-identifier">update_payload_attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:payload_type</span>)
- <span class="ruby-identifier">update_payload_attrs</span>
-<span class="ruby-keyword">end</span></pre>
- </div>
- </div>
-
-
- </div>
-
- <div id="method-i-updated_relations_attrs" class="method-detail ">
- <div class="method-header">
- <div class="method-heading">
- <span class="method-name">updated_relations_attrs</span><span
- class="method-args">()</span>
- <span class="method-click-advice">click to toggle source</span>
- </div>
- </div>
-
- <div class="method-description">
- <p>Returns the attributes for the updated relations.</p>
-
- <div class="method-source-code" id="updated_relations_attrs-source">
- <pre><span class="ruby-comment"># File lib/loggable_activity/activity.rb, line 194</span>
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">updated_relations_attrs</span>
- <span class="ruby-identifier">grouped_associations</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">group_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:record_type</span>] }
-
- <span class="ruby-identifier">grouped_associations</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">record_type</span>, <span class="ruby-identifier">payloads</span><span class="ruby-operator">|</span>
- <span class="ruby-identifier">previous_attrs</span> = <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">'previous_association'</span> }
- <span class="ruby-identifier">current_attrs</span> = <span class="ruby-identifier">payloads</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:payload_type</span>] <span class="ruby-operator">==</span> <span class="ruby-string">'current_association'</span> }
- <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">previous_attrs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">current_attrs</span>.<span class="ruby-identifier">nil?</span>
-
- { <span class="ruby-value">record_type:</span>, <span class="ruby-value">previous_attrs:</span>, <span class="ruby-value">current_attrs:</span> }
- <span class="ruby-keyword">end</span>.<span class="ruby-identifier">compact</span>
+ <span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">EncryptionKey</span>.<span class="ruby-identifier">for_record</span>(<span class="ruby-identifier">record</span>)&.<span class="ruby-identifier">secret_key</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>