doc/Dynamoid/Indexes/Index.html in dynamoid-0.4.0 vs doc/Dynamoid/Indexes/Index.html in dynamoid-0.4.1
- old
+ new
@@ -225,11 +225,11 @@
<ul class="summary">
<li class="public ">
<span class="summary_signature">
- <a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(obj) </a>
+ <a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(obj, changed_attributes = false) </a>
</span>
@@ -360,11 +360,11 @@
<li class="public ">
<span class="summary_signature">
- <a href="#values-instance_method" title="#values (instance method)">- (Hash) <strong>values</strong>(attrs) </a>
+ <a href="#values-instance_method" title="#values (instance method)">- (Hash) <strong>values</strong>(attrs, changed_attributes = false) </a>
</span>
@@ -688,11 +688,11 @@
<div class="method_details first">
<p class="signature first" id="delete-instance_method">
- - (<tt>Object</tt>) <strong>delete</strong>(obj)
+ - (<tt>Object</tt>) <strong>delete</strong>(obj, changed_attributes = false)
</p><div class="docstring">
<div class="discussion">
@@ -724,25 +724,25 @@
<tr>
<td>
<pre class="lines">
-84
-85
-86
-87
-88
-89
-90</pre>
+93
+94
+95
+96
+97
+98
+99</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 84</span>
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 93</span>
-<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
+<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:range_key</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>unless</span> <span class='id identifier rubyid_existing'>existing</span> <span class='op'>&&</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
<span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:id</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='symbol'>:ids</span> <span class='op'>=></span> <span class='lparen'>(</span><span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span> <span class='op'>-</span> <span class='const'>Set</span><span class='lbracket'>[</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -809,11 +809,12 @@
</p><div class="docstring">
<div class="discussion">
- <p>Save an object to this index, merging it with existing ids if there's already something present at this index location.</p>
+ <p>Save an object to this index, merging it with existing ids if there's already something present at this index location.
+First, though, delete this object from its old indexes (so the object isn't listed in an erroneous index).</p>
</div>
</div>
<div class="tags">
@@ -838,25 +839,27 @@
<tr>
<td>
<pre class="lines">
-72
-73
-74
-75
-76
-77
-78</pre>
+80
+81
+82
+83
+84
+85
+86
+87</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 72</span>
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 80</span>
<span class='kw'>def</span> <span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:range_key</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_existing'>existing</span> <span class='kw'>and</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
<span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:id</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='symbol'>:ids</span> <span class='op'>=></span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -979,17 +982,19 @@
</div>
<div class="method_details ">
<p class="signature " id="values-instance_method">
- - (<tt>Hash</tt>) <strong>values</strong>(attrs)
+ - (<tt>Hash</tt>) <strong>values</strong>(attrs, changed_attributes = false)
</p><div class="docstring">
<div class="discussion">
- <p>Given either an object or a list of attributes, generate a hash key and a range key for the index.</p>
+ <p>Given either an object or a list of attributes, generate a hash key and a range key for the index. Optionally pass in
+true to changed_attributes for a list of all the object's dirty attributes in convenient index form (for deleting stale
+information from the indexes).</p>
</div>
</div>
<div class="tags">
@@ -1050,22 +1055,32 @@
<tr>
<td>
<pre class="lines">
-61
-62
63
64
65
66
-67</pre>
+67
+68
+69
+70
+71
+72
+73
+74</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 61</span>
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 63</span>
-<span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
+<span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
+ <span class='kw'>if</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span>
+ <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
+ <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_changes'>changes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>||</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='rparen'>)</span><span class='rbrace'>}</span>
+ <span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
+ <span class='kw'>end</span>
<span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:attributes</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:attributes</span><span class='rparen'>)</span>
<span class='lbrace'>{</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_hash_keys'>hash_keys</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_range_keys'>range_keys</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='float'>0.0</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_sum'>sum</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>+</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_range_key?'>range_key?</span>
<span class='kw'>end</span>
@@ -1078,10 +1093,10 @@
</div>
</div>
<div id="footer">
- Generated on Tue Mar 27 17:53:07 2012 by
+ Generated on Thu Apr 26 01:26:25 2012 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.7.5 (ruby-1.9.3).
</div>
</body>
\ No newline at end of file