<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AOP on Peczenyj's Blog</title><link>http://pacman.blog.br/categories/aop/</link><description>Recent content in AOP on Peczenyj's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 07 Feb 2014 20:13:00 +0000</lastBuildDate><atom:link href="http://pacman.blog.br/categories/aop/atom.xml" rel="self" type="application/rss+xml"/><item><title>MooseX - a new Ruby DSL for Object Oriented Programming (and much more)</title><link>http://pacman.blog.br/blog/2014/02/07/moosex-a-new-ruby-dsl-for-object-oriented-programming-and-much-more/</link><pubDate>Fri, 07 Feb 2014 20:13:00 +0000</pubDate><guid>http://pacman.blog.br/blog/2014/02/07/moosex-a-new-ruby-dsl-for-object-oriented-programming-and-much-more/</guid><description>&lt;p>MooseX is a postmodern object DSL for Ruby &lt;a href="https://travis-ci.org/peczenyj/MooseX">&lt;img src="https://travis-ci.org/peczenyj/MooseX.png" alt="Build Status">&lt;/a> &lt;a href="http://badge.fury.io/rb/moosex">&lt;img src="https://badge.fury.io/rb/moosex.png" alt="Gem Version">&lt;/a>&lt;/p>
&lt;p>This is a DSL for object creation, aspects, method delegation and much more. It is based on Perl Moose and Moo, two important modules who add a better way of Object Orientation development (and I enjoy A LOT). Using a declarative stype, using Moose/Moo you can create attributes, methods, the entire constructor and much more. But I can&amp;rsquo;t find something similar in Ruby world, so I decide port a small subset of Moose to create a powerfull DSL for object construction.&lt;/p></description></item><item><title>Adding a 'dry run' capability to your Moose class with MooseX::Role::DryRunnable</title><link>http://pacman.blog.br/blog/2013/04/07/adding-a-dry-run-capability-to-your-moose-class-with-moosex-role-dryrunnable/</link><pubDate>Sun, 07 Apr 2013 09:55:00 +0000</pubDate><guid>http://pacman.blog.br/blog/2013/04/07/adding-a-dry-run-capability-to-your-moose-class-with-moosex-role-dryrunnable/</guid><description>&lt;p>A &amp;lsquo;dry run&amp;rsquo; is a testing process where the effects of a possible failure are intentionally mitigated. For example, an aerospace company may conduct a &amp;ldquo;dry run&amp;rdquo; test of a jet&amp;rsquo;s new pilot ejection seat while the jet is parked on the ground, rather than while it is in flight. Or, in software development, we can change the behavior of some methods in order to test, like avoid change data into a database (logging the action instead).&lt;/p>
&lt;p>There are many ways to implement this capability. For example, we can add an explicity return in each method and test some condition. I will show some options in this article and we will find how to use the module &lt;a href="https://metacpan.org/module/MooseX::Role::DryRunnable">MooseX::Role::DryRunnable&lt;/a> in our Moose classes (Perl).&lt;/p>
&lt;p>One simple example in Perl, reading from an environment variable &lt;code>DRY_RUN&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-perl" data-lang="perl">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">package&lt;/span> Foo;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#719e07">sub&lt;/span> &lt;span style="color:#268bd2">bar&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>	logger&lt;span style="color:#719e07">-&amp;gt;&lt;/span>debug(&lt;span style="color:#2aa198">&amp;#34;Foo::bar @_&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>	&lt;span style="color:#719e07">return&lt;/span> &lt;span style="color:#719e07">if&lt;/span> &lt;span style="color:#268bd2">$ENV&lt;/span>{&lt;span style="color:#2aa198">&amp;#39;DRY_RUN&amp;#39;&lt;/span>};
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>	&lt;span style="color:#719e07">...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>