|
50 | 50 | and tracking user referrals.</p> |
51 | 51 |
|
52 | 52 | <p><a href="http://travis-ci.org/mceachen/closure_tree"><img src="https://secure.travis-ci.org/mceachen/closure_tree.png?branch=master" alt="Build Status"></a> |
53 | | -<a href="http://rubygems.org/gems/closure_tree"><img src="https://badge.fury.io/rb/closure_tree.png" alt="Gem Version"></a></p> |
| 53 | +<a href="http://rubygems.org/gems/closure_tree"><img src="https://badge.fury.io/rb/closure_tree.png" alt="Gem Version"></a> |
| 54 | +<a href="https://codeclimate.com/github/mceachen/closure_tree"><img src="https://codeclimate.com/github/mceachen/closure_tree.png" alt="Code Climate"></a></p> |
54 | 55 |
|
55 | 56 | <p>Substantially more efficient than |
56 | 57 | <a href="https://github.com/stefankroes/ancestry">ancestry</a> and |
|
211 | 212 | column is <code>name</code>, which can be changed with the :name_column option |
212 | 213 | provided to <code>acts_as_tree</code>.</p> |
213 | 214 |
|
214 | | -<p>Note that any other AR fields can be set with the second, optional <code>attributes</code> argument.</p> |
| 215 | +<p>Note that any other AR fields can be set with the second, optional <code>attributes</code> argument, |
| 216 | +and as of version 4.2.0, these attributes are added to the where clause as selection criteria.</p> |
215 | 217 |
|
216 | 218 | <div class="highlight"><pre><span class="n">child</span> <span class="o">=</span> <span class="no">Tag</span><span class="o">.</span><span class="n">find_or_create_by_path</span><span class="p">(</span><span class="sx">%w{home chuck Photos"}</span><span class="p">,</span> <span class="p">{</span><span class="ss">:tag_type</span> <span class="o">=></span> <span class="s2">"File"</span><span class="p">})</span> |
217 | 219 | </pre></div> |
@@ -332,11 +334,13 @@ <h3> |
332 | 334 | <li> |
333 | 335 | <code>Tag.hash_tree</code> returns an <a href="#nested-hashes">ordered, nested hash</a> that can be depth-limited.</li> |
334 | 336 | <li> |
335 | | -<code>Tag.find_by_path(path)</code> returns the node whose name path is <code>path</code>. See (#find_or_create_by_path).</li> |
| 337 | +<code>Tag.find_by_path(path, attributes)</code> returns the node whose name path is <code>path</code>. See (#find_or_create_by_path).</li> |
336 | 338 | <li> |
337 | | -<code>Tag.find_or_create_by_path(path)</code> returns the node whose name path is <code>path</code>, and will create the node if it doesn't exist already.See (#find_or_create_by_path).</li> |
| 339 | +<code>Tag.find_or_create_by_path(path, attributes)</code> returns the node whose name path is <code>path</code>, and will create the node if it doesn't exist already.See (#find_or_create_by_path).</li> |
338 | 340 | <li> |
339 | 341 | <code>Tag.find_all_by_generation(generation_level)</code> returns the descendant nodes who are <code>generation_level</code> away from a root. <code>Tag.find_all_by_generation(0)</code> is equivalent to <code>Tag.roots</code>.</li> |
| 342 | +<li> |
| 343 | +<code>Tag.with_ancestor(ancestors)</code> scopes to all descendants whose ancestor is in the given list.</li> |
340 | 344 | </ul><h3> |
341 | 345 | <a name="instance-methods" class="anchor" href="#instance-methods"><span class="octicon octicon-link"></span></a>Instance methods</h3> |
342 | 346 |
|
@@ -590,6 +594,19 @@ <h2> |
590 | 594 | <a name="change-log" class="anchor" href="#change-log"><span class="octicon octicon-link"></span></a>Change log</h2> |
591 | 595 |
|
592 | 596 | <h3> |
| 597 | +<a name="420" class="anchor" href="#420"><span class="octicon octicon-link"></span></a>4.2.0</h3> |
| 598 | + |
| 599 | +<ul> |
| 600 | +<li>Added <code>with_ancestor(*ancestors)</code>. Thanks for the idea, <a href="https://github.com/mgornick">Matt</a>!</li> |
| 601 | +<li>Applied <a href="https://github.com/leonelgalan">Leonel Galan</a>'s fix for Strong Attribute support</li> |
| 602 | +<li> |
| 603 | +<code>find_or_create_by</code> now uses passed-in attributes as both selection and creation criteria. |
| 604 | +Thanks for the help, <a href="https://github.com/juddblair">Judd Blair</a>! |
| 605 | +<strong>Please note that this changes prior behavior—test your code with this new version!</strong> |
| 606 | +</li> |
| 607 | +<li> |
| 608 | +<code>ct_advisory_lock</code> was moved into the <code>_ct</code> support class, to reduce model method pollution</li> |
| 609 | +</ul><h3> |
593 | 610 | <a name="410" class="anchor" href="#410"><span class="octicon octicon-link"></span></a>4.1.0</h3> |
594 | 611 |
|
595 | 612 | <ul> |
|
0 commit comments