<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Private Member Variables in Ruby</title>
	<atom:link href="http://www.railsrocket.com/private-member-variables-in-ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.railsrocket.com/private-member-variables-in-ruby</link>
	<description>A Ruby on Rails community website with tutorials</description>
	<lastBuildDate>Thu, 25 Mar 2010 23:45:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Wayne Conrad</title>
		<link>http://www.railsrocket.com/private-member-variables-in-ruby/comment-page-1#comment-390</link>
		<dc:creator>Wayne Conrad</dc:creator>
		<pubDate>Wed, 17 Dec 2008 20:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsrocket.com/articles/?p=234#comment-390</guid>
		<description>You can make private accessors by putting the attr_... helper inside the private section of the class:

#!/usr/bin/ruby1.8

class Foo

  def set_baz
    self.baz = 2
  end

  def show_baz
    puts &quot;baz = #{baz}&quot;
  end
  
  private

  attr_accessor :baz

end

foo = Foo.new
foo.set_baz
foo.show_baz # prints &#039;2&#039;
p foo.baz # Fails: &quot;private method &#039;baz&#039; called&quot;</description>
		<content:encoded><![CDATA[<p>You can make private accessors by putting the attr_&#8230; helper inside the private section of the class:</p>
<p>#!/usr/bin/ruby1.8</p>
<p>class Foo</p>
<p>  def set_baz<br />
    self.baz = 2<br />
  end</p>
<p>  def show_baz<br />
    puts &#8220;baz = #{baz}&#8221;<br />
  end</p>
<p>  private</p>
<p>  attr_accessor :baz</p>
<p>end</p>
<p>foo = Foo.new<br />
foo.set_baz<br />
foo.show_baz # prints &#8217;2&#8242;<br />
p foo.baz # Fails: &#8220;private method &#8216;baz&#8217; called&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

