You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<linkrel="prev" title="Brilliant – My Very Own Programming Language" href="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/2014/03/30/brilliant-my-own-programming-language"/>
32
-
<linkrel="next" title="TDD Is Alive And Well" href="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/2014/05/05/tdd-is-alive-and-well"/>
31
+
<linkrel="prev" title="Brilliant – My Very Own Programming Language" href="http://blog.boochtek.com/2014/03/30/brilliant-my-own-programming-language"/>
32
+
<linkrel="next" title="TDD Is Alive And Well" href="http://blog.boochtek.com/2014/05/05/tdd-is-alive-and-well"/>
<p>But that’s not valid Ruby; <code>include</code> doesn’t let you pass anything other than a module.</p>
97
-
<p>So when I was learning about <ahref="https://web.archive.org/web/20150824185026/https://github.com/solnic/virtus">Virtus</a>, I noticed that its example of how to include it is a bit different than the standard Ruby idiomatic <code>include</code>:</p>
97
+
<p>So when I was learning about <ahref="https://github.com/solnic/virtus">Virtus</a>, I noticed that its example of how to include it is a bit different than the standard Ruby idiomatic <code>include</code>:</p>
<p>We could even pass a block. But how do we process those options? There are a few different ways. However we do it, we have to be sure to return a module. And we can create modules in a few different ways.</p>
118
118
<p>Virtus uses the builder pattern. It takes the parameters passed in and builds a module dynamically. By that, I mean that it calls <code>Module.new</code> and then adds methods to that module. It does this by mixing in other modules, but it could do it by dynamically defining methods as well.</p>
119
119
<p>I’ve never seen this pattern in any other language. It’s obviously only possible because we can dynamically create modules.</p>
120
-
<p>The use of this idiom seems to be catching on a bit in the Ruby community. I’ve started using it myself, and will be adding it to my <ahref="https://web.archive.org/web/20150824185026/https://github.com/boochtek/includable-activerecord">Includable::ActiveRecord</a> gem soon.</p>
120
+
<p>The use of this idiom seems to be catching on a bit in the Ruby community. I’ve started using it myself, and will be adding it to my <ahref="https://github.com/boochtek/includable-activerecord">Includable::ActiveRecord</a> gem soon.</p>
121
121
<p> </p>
122
122
<p> </p>
123
123
</div><!-- .entry-content -->
124
124
125
125
<footerclass="entry-meta">
126
-
This entry was posted in <ahref="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/category/programming/programming-languages/ruby" title="View all posts in Ruby" rel="category tag">Ruby</a> by <ahref="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/author/booch">Craig Buchek</a>. Bookmark the <ahref="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion" title="Permalink to Ruby Pattern: Parameterized Module Inclusion" rel="bookmark">permalink</a>.
126
+
This entry was posted in <ahref="http://blog.boochtek.com/category/programming/programming-languages/ruby" title="View all posts in Ruby" rel="category tag">Ruby</a> by <ahref="http://blog.boochtek.com/author/booch">Craig Buchek</a>. Bookmark the <ahref="http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion" title="Permalink to Ruby Pattern: Parameterized Module Inclusion" rel="bookmark">permalink</a>.
127
127
</footer><!-- .entry-meta -->
128
128
</article><!-- #post-184 -->
129
129
@@ -139,7 +139,7 @@ <h2 id="comments-title">
139
139
<articleid="comment-2718" class="comment">
140
140
<footerclass="comment-meta">
141
141
<divclass="comment-author vcard">
142
-
<imgalt="" src="https://web.archive.org/web/20150824185026im_/http://1.gravatar.com/avatar/f04aeb28129f653b207e8b5d92706096?s=68&d=blank&r=G" class="avatar avatar-68 photo" height="68" width="68"/><spanclass="fn"><ahref="https://web.archive.org/web/20150824185026/http://dirtyinformation.com/" rel="external nofollow" class="url">Amos King</a></span> on <ahref="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion/comment-page-1#comment-2718"><timedatetime="2014-05-27T22:48:51+00:00">May 27, 2014 at 10:48 PM</time></a><spanclass="says">said:</span>
142
+
<imgalt="" src="http://1.gravatar.com/avatar/f04aeb28129f653b207e8b5d92706096?s=68&d=blank&r=G" class="avatar avatar-68 photo" height="68" width="68"/><spanclass="fn"><ahref="http://dirtyinformation.com/" rel="external nofollow" class="url">Amos King</a></span> on <ahref="http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion/comment-page-1#comment-2718"><timedatetime="2014-05-27T22:48:51+00:00">May 27, 2014 at 10:48 PM</time></a><spanclass="says">said:</span>
143
143
</div><!-- .comment-author .vcard -->
144
144
145
145
@@ -164,7 +164,7 @@ <h2 id="comments-title">
164
164
<articleid="comment-2730" class="comment">
165
165
<footerclass="comment-meta">
166
166
<divclass="comment-author vcard">
167
-
<imgalt="" src="https://web.archive.org/web/20150824185026im_/http://1.gravatar.com/avatar/52bfd7cb9ac37808464919f9685ca62f?s=68&d=blank&r=G" class="avatar avatar-68 photo" height="68" width="68"/><spanclass="fn">Craig Buchek</span> on <ahref="https://web.archive.org/web/20150824185026/http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion/comment-page-1#comment-2730"><timedatetime="2014-05-31T10:49:14+00:00">May 31, 2014 at 10:49 AM</time></a><spanclass="says">said:</span>
167
+
<imgalt="" src="http://1.gravatar.com/avatar/52bfd7cb9ac37808464919f9685ca62f?s=68&d=blank&r=G" class="avatar avatar-68 photo" height="68" width="68"/><spanclass="fn">Craig Buchek</span> on <ahref="http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion/comment-page-1#comment-2730"><timedatetime="2014-05-31T10:49:14+00:00">May 31, 2014 at 10:49 AM</time></a><spanclass="says">said:</span>
168
168
</div><!-- .comment-author .vcard -->
169
169
170
170
@@ -200,7 +200,7 @@ <h2 id="comments-title">
200
200
201
201
<divid="respond" class="comment-respond">
202
202
<h3id="reply-title" class="comment-reply-title">Leave a Reply <small><arel="nofollow" id="cancel-comment-reply-link" href="/web/20150824185026/http://blog.boochtek.com/2014/04/14/ruby-parameterized-module-inclusion/comment-page-1#respond" style="display:none;">Cancel reply</a></small></h3>
<pclass="comment-notes">Your email address will not be published. Required fields are marked <spanclass="required">*</span></p><pclass="comment-form-author"><labelfor="author">Name <spanclass="required">*</span></label><inputid="author" name="author" type="text" value="" size="30" aria-required="true"/></p>
<ahref="https://web.archive.org/web/20150824185026/http://wordpress.org/" title="Semantic Personal Publishing Platform">Proudly powered by WordPress</a>
229
+
<ahref="http://wordpress.org/" title="Semantic Personal Publishing Platform">Proudly powered by WordPress</a>
0 commit comments