<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Robert Rossol on Medium]]></title>
        <description><![CDATA[Stories by Robert Rossol on Medium]]></description>
        <link>https://medium.com/@robertrossol?source=rss-7c3f03d667a9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gDSw3tAYY0-IFSM2.</url>
            <title>Stories by Robert Rossol on Medium</title>
            <link>https://medium.com/@robertrossol?source=rss-7c3f03d667a9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 08:54:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@robertrossol/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Namespacing: Modules’ other main job]]></title>
            <link>https://medium.com/@robertrossol/namespacing-modules-other-main-job-5f391a7ef391?source=rss-7c3f03d667a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f391a7ef391</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[namespacing]]></category>
            <dc:creator><![CDATA[Robert Rossol]]></dc:creator>
            <pubDate>Mon, 28 Mar 2022 02:11:53 GMT</pubDate>
            <atom:updated>2022-03-28T02:11:53.231Z</atom:updated>
            <content:encoded><![CDATA[<p>The first thing we learn about modules is that they can be used to mix common behaviors into multiple classes, but this is far from modules’ only function. In fact, namespacing, modules’ other most common use case, is integral to creating well designed applications and avoiding naming collisions between classes (especially when loading in multiple libraries). Let’s take a look at how this works in Ruby.</p><p>By grouping multiple related classes together within a module we make our code much more organized and easier to read and keep track of. For example, if we have multiple classes of different animals we could look for ways to organize these classes by using namespacing to group the animals into different groups based on some attribute or specification. In the code below we’ve chosen to split the animals based on whether they are ‘domesticated’ or ‘wild’.</p><pre>module Domesticated<br>  class Cat; end<br>  class Dog; end<br>end</pre><pre>module Wild<br>  class Alligator; end<br>  class Zebra;  end<br>end</pre><p>Namespacing also allows multiple classes, methods, and constants with the same name to coexist within our applications by scoping them within modules and accessing them via Constant Lookup operator(::). For example, in the code below we have two separate Cat classes namespaced into our two separate modules: Domesticated and Wild.</p><pre>module Domesticated<br>  class Cat<br>    def sound<br>      &quot;meow&quot;<br>    end<br>  end<br>end</pre><pre>module Wild<br>  class Cat<br>    def sound<br>      &quot;roar&quot;<br>    end<br>  end<br>end</pre><p>Without namespacing, having two different Cat classes would be a conflict and Ruby would overwrite the first sound method’s definition with the second’s definition. Fortunately, with our namespaced implementation we can now access both separate Cat classes and their methods, like so:</p><pre>kitty = Domesticated::Cat.new<br>simba = Wild::Cat.new</pre><pre>kitty.sound # =&gt; &quot;meow&quot;<br>simba.sound # =&gt; &quot;roar&quot;</pre><p>And those are the basics of namespacing in Ruby!</p><p>TLDR: Main benefits of namespacing:<br>- Helps with organizing code by grouping related methods<br>- Helps avoid naming collisions</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f391a7ef391" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Helper Methods]]></title>
            <link>https://medium.com/@robertrossol/helper-methods-4bba9b5c7da6?source=rss-7c3f03d667a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bba9b5c7da6</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Robert Rossol]]></dc:creator>
            <pubDate>Sun, 26 Mar 2017 18:07:02 GMT</pubDate>
            <atom:updated>2017-03-26T18:07:02.848Z</atom:updated>
            <content:encoded><![CDATA[<p>Despite covering many integral topics in the last few weeks, one understated resource that intrigues me is helper methods. These controller methods can, for example, widen the scope of certain information, allowing it to be accessed from wider views. For example, the following code allows us to utilize the current_user function in other controllers and views, allowing us flexible access to integral information throughout our applications:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6ff88522faeb06e5a97c58632d51288/href">https://medium.com/media/f6ff88522faeb06e5a97c58632d51288/href</a></iframe><p>When utilized, these helper methods should greatly assist in keeping code DRY and understandable for future viewers.</p><p>The following link has some good examples of commonly used helper methods:</p><p><a href="http://archive.oreilly.com/pub/a/ruby/excerpts/ruby-learning-rails/ruby-catalog-helper-methods.html">http://archive.oreilly.com/pub/a/ruby/excerpts/ruby-learning-rails/ruby-catalog-helper-methods.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bba9b5c7da6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ruby .select on array of hashes]]></title>
            <link>https://medium.com/@robertrossol/ruby-select-on-array-of-arrays-f8d7dd4402ab?source=rss-7c3f03d667a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8d7dd4402ab</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Robert Rossol]]></dc:creator>
            <pubDate>Mon, 13 Mar 2017 18:06:10 GMT</pubDate>
            <atom:updated>2017-03-13T18:08:57.781Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most useful techniques I discovered this week is the .select method, and by experimenting a bit I figured out how to utilize this versatile method on multiple different data types.</p><p>Running through a hash is pretty straight forward and will return a hash with the selected elements ({cat: 2, monkey: 4, parrot: 2} in the following example).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9103f7a2e6e31ff231cd26d4dff2061b/href">https://medium.com/media/9103f7a2e6e31ff231cd26d4dff2061b/href</a></iframe><p>Using .select in conjunction in conjunction with the .map method on more complicated data structures-such as an array of hashes-gets much more interesting and useful. The following example shows one way to use these methods to return only the id’s of the films from an array that contain a certain letter:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd1093fb3e26d9ecdcd4c9d41a977cf2/href">https://medium.com/media/bd1093fb3e26d9ecdcd4c9d41a977cf2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8d7dd4402ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>