<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Irish Penguin &#187; static singleton class methods include extend module mixin ruby rails</title>
	<atom:link href="http://www.theirishpenguin.com/tag/static-singleton-class-methods-include-extend-module-mixin-ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theirishpenguin.com</link>
	<description>Watching Open Source unfold across Ireland</description>
	<lastBuildDate>Sun, 25 Jul 2010 17:53:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Ruby Module that mixes in Class Methods (static) and Instance Methods</title>
		<link>http://www.theirishpenguin.com/2010/02/04/a-ruby-module-that-mixes-in-class-methods-static-and-instance-methods/</link>
		<comments>http://www.theirishpenguin.com/2010/02/04/a-ruby-module-that-mixes-in-class-methods-static-and-instance-methods/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 23:08:34 +0000</pubDate>
		<dc:creator>theirishpenguin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[RubyIreland]]></category>
		<category><![CDATA[Rubyonrails]]></category>
		<category><![CDATA[static singleton class methods include extend module mixin ruby rails]]></category>

		<guid isPermaLink="false">http://www.theirishpenguin.com/?p=445</guid>
		<description><![CDATA[Ho ho, this one can catch you out more than once so it&#8217;s high time to write a blog post to cover this off. Turns out it&#8217;s a commonly used pattern to the rescue. Thanks to eoin on #ruby.ie for pointing to the solution on RailsTips.org.
Here&#8217;s quite a tasty diagram too for easy reference.

module Swingable

 [...]]]></description>
			<content:encoded><![CDATA[<p>Ho ho, this one can catch you out more than once so it&#8217;s high time to write a blog post to cover this off. Turns out it&#8217;s a commonly used pattern to the rescue. Thanks to eoin on #ruby.ie for pointing to the solution on <a href="http://railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/">RailsTips.org</a>.</p>
<p>Here&#8217;s quite a tasty diagram too for <a href="http://smartbomb.com.au/2009/02/an-idiom">easy reference</a>.</p>
<pre>
module Swingable

    def self.included(base)
        base.extend(ClassMethods)
    end

    def instance_swing
        puts 'Did an instance swing!'
    end

    module ClassMethods
        def static_swing
            puts 'Did a static swing!'
        end
    end
end

class BaseballBat
   include Swingable
end

BaseballBat.static_swing
BaseballBat.new.instance_swing
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.theirishpenguin.com/2010/02/04/a-ruby-module-that-mixes-in-class-methods-static-and-instance-methods/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
