<?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>Easy Ruby On Rails Programming &#187; closure</title>
	<atom:link href="http://easyrubyonrailsprogramming.com/tag/closure/feed/" rel="self" type="application/rss+xml" />
	<link>http://easyrubyonrailsprogramming.com</link>
	<description>The Place to be to Learn Ruby On Rails</description>
	<lastBuildDate>Sat, 24 Dec 2011 05:30:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Blocks as Closures (Part 3)</title>
		<link>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-3/</link>
		<comments>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-3/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 10:25:55 +0000</pubDate>
		<dc:creator>Avatar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming Basics]]></category>
		<category><![CDATA[Blocks]]></category>
		<category><![CDATA[closure]]></category>

		<guid isPermaLink="false">http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-3/</guid>
		<description><![CDATA[That&#8217;s where blocks come in, to simplify the definition and use of these buttons making maintenance simpler so we could call the specific block to which we pass on the necessary parameters or methods to attain the final outcome. Below is an example of how this can be achieved with blocks creating a class called [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/"><img src="/wp-content/uploads/scraped/34.jpg"/></a>
<p>That&#8217;s where blocks come in, to simplify the definition and use of these buttons making maintenance simpler so we could call the specific block to which we pass on the necessary parameters or methods to attain the final outcome. Below is an example of how this can be achieved with blocks creating a class called devicebutton:</p>
<p>class DeviceButton < Button<br />
  def initialize(label, &#038;process)<br />
    super(label)<br />
    @action = action<br />
  end<br />
  def buttonSelected<br />
    @action.call(self)<br />
  end<br />
end</p>
<p>bPlay  = DeviceButton.new(&#8220;Play&#8221;)  {cdList.play}<br />
bPause = DeviceButton.new(&#8220;Pause&#8221;) {cdList.pause}</p>
]]></content:encoded>
			<wfw:commentRss>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocks as Closures (Part 2)</title>
		<link>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-2/</link>
		<comments>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-2/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 10:25:13 +0000</pubDate>
		<dc:creator>Avatar</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming Basics]]></category>
		<category><![CDATA[Blocks]]></category>
		<category><![CDATA[closure]]></category>

		<guid isPermaLink="false">http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-2/</guid>
		<description><![CDATA[Sample Code: class PlayButton < Button def initialize super(&#8220;Play&#8221;) # invoke Button&#8217;s initialize process end def buttonSelected # do something that should be done when the start button is pressed end end bPlay = PlayButton.new This type of approach would bring about two very problematic scenarios; one, the actions that are to be done when [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/"><img src="/wp-content/uploads/scraped/33.jpg"/></a>
<p>Sample Code:</p>
<p>class PlayButton < Button<br />
  def initialize<br />
    super(&#8220;Play&#8221;)       # invoke Button&#8217;s initialize process<br />
  end<br />
  def buttonSelected<br />
    # do something that should be done when the start button is pressed<br />
  end<br />
end</p>
<p>bPlay = PlayButton.new</p>
<p>This type of approach would bring about two very problematic scenarios; one, the actions that are to be done when a button is selected and pressed is not a function of the button itself but of the overall device which has the buttons as interface; and last, this would have us making tons of buttons that would correspond to all the function the overall device that if the said button&#8217;s features or process were to change that would create a ton of maintenance issues in efforts to re-define those buttons to do all the different functions buttons should do in the whole application/device. </p>
]]></content:encoded>
			<wfw:commentRss>http://easyrubyonrailsprogramming.com/development/blocks-as-closures-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

