docs/lib/rep.html in rep-0.0.4 vs docs/lib/rep.html in rep-0.1.0

- old
+ new

@@ -88,31 +88,29 @@ <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>All classes that <code>include Rep</code> are extended with <code>Forwardable</code>, given some aliases, endowned with <code>HashieSupport</code> if Hashie is loaded, -and setup an empty <code>#parse_opts</code> because it is required for <code>::shared</code>.</p> +and given a delegate method if it doesn&rsquo;t already have one.</p> </td> <td class=code> <div class='highlight'><pre> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">included</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span> <span class="n">klass</span><span class="o">.</span><span class="n">extend</span> <span class="no">Forwardable</span> <span class="n">klass</span><span class="o">.</span><span class="n">extend</span> <span class="no">ClassMethods</span> <span class="n">klass</span><span class="o">.</span><span class="n">instance_eval</span> <span class="p">{</span> <span class="k">class</span> <span class="o">&lt;&lt;</span> <span class="nb">self</span> - <span class="k">alias</span> <span class="n">forward</span> <span class="n">delegate</span> + <span class="k">unless</span> <span class="n">defined?</span><span class="p">(</span><span class="n">forward</span><span class="p">)</span> + <span class="k">alias</span> <span class="n">forward</span> <span class="n">delegate</span> + <span class="k">end</span> <span class="k">unless</span> <span class="n">defined?</span><span class="p">(</span><span class="n">fields</span><span class="p">)</span> <span class="k">alias</span> <span class="n">fields</span> <span class="n">json_fields</span> <span class="k">end</span> - - <span class="k">if</span> <span class="n">defined?</span><span class="p">(</span><span class="no">Hashie</span><span class="p">)</span> - <span class="kp">include</span> <span class="no">HashieSupport</span> - <span class="k">end</span> <span class="k">end</span> - <span class="k">unless</span> <span class="n">defined?</span><span class="p">(</span><span class="n">parse_opts</span><span class="p">)</span> - <span class="k">def</span> <span class="nf">parse_opts</span><span class="p">(</span><span class="n">opts</span> <span class="o">=</span> <span class="p">{});</span> <span class="k">end</span> + <span class="k">if</span> <span class="n">defined?</span><span class="p">(</span><span class="no">Mashed</span><span class="p">)</span> + <span class="kp">include</span> <span class="no">MashedSupport</span> <span class="k">end</span> <span class="p">}</span> <span class="k">end</span></pre></div> </td> </tr> @@ -221,12 +219,17 @@ <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Remember what args we normally initialize with so we can refer to them when building shared instances.</p> </td> <td class=code> - <div class='highlight'><pre> <span class="n">define_singleton_method</span> <span class="ss">:initializiation_args</span> <span class="k">do</span> - <span class="vi">@initializiation_args</span> + <div class='highlight'><pre> <span class="k">if</span> <span class="n">defined?</span><span class="p">(</span><span class="n">define_singleton_method</span><span class="p">)</span> + <span class="n">define_singleton_method</span> <span class="ss">:initializiation_args</span> <span class="k">do</span> + <span class="vi">@initializiation_args</span> + <span class="k">end</span> + <span class="k">else</span> + <span class="n">singleton</span> <span class="o">=</span> <span class="k">class</span> <span class="o">&lt;&lt;</span> <span class="nb">self</span><span class="p">;</span> <span class="nb">self</span> <span class="k">end</span> + <span class="n">singleton</span><span class="o">.</span><span class="n">send</span> <span class="ss">:define_method</span><span class="p">,</span> <span class="ss">:initializiation_args</span><span class="p">,</span> <span class="nb">lambda</span> <span class="p">{</span> <span class="vi">@initializiation_args</span> <span class="p">}</span> <span class="k">end</span></pre></div> </td> </tr> <tr id='section-10'> <td class=docs> @@ -236,11 +239,14 @@ <p>Create an <code>attr_accessor</code> for each one. Defaults can be provided using the Hash version { :arg => :default_value }</p> </td> <td class=code> <div class='highlight'><pre> <span class="n">args</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span> <span class="o">|</span><span class="n">a</span><span class="o">|</span> <span class="n">register_accessor</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="p">}</span> - <span class="n">define_method</span><span class="p">(</span><span class="ss">:initialize</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">opts</span> <span class="o">=</span> <span class="p">{}</span><span class="o">|</span> <span class="n">parse_opts</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span> <span class="p">}</span></pre></div> + <span class="n">define_method</span><span class="p">(</span><span class="ss">:initialize</span><span class="p">)</span> <span class="p">{</span> <span class="o">|*</span><span class="n">args</span><span class="o">|</span> + <span class="n">opts</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">first</span> <span class="o">||</span> <span class="p">{}</span> + <span class="n">parse_opts</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span> + <span class="p">}</span></pre></div> </td> </tr> <tr id='section-11'> <td class=docs> <div class="pilwrap"> @@ -463,12 +469,12 @@ <span class="n">shared</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">to_hash</span> <span class="p">}</span> <span class="k">end</span> <span class="k">end</span> - <span class="k">module</span> <span class="nn">HashieSupport</span> + <span class="k">module</span> <span class="nn">MashedSupport</span> <span class="k">def</span> <span class="nf">to_hash</span><span class="p">(</span><span class="nb">name</span> <span class="o">=</span> <span class="ss">:default</span><span class="p">)</span> - <span class="no">Hashie</span><span class="o">::</span><span class="no">Mash</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="k">super</span><span class="p">)</span> + <span class="no">Mashed</span><span class="o">::</span><span class="no">Mash</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="k">super</span><span class="p">)</span> <span class="k">end</span> <span class="k">end</span> <span class="k">end</span></pre></div> </td> </tr>