Mailinglist Archive: opensuse-ruby (15 mails)

< Previous Next >
Re: [opensuse-ruby] HelpNeeded: ActiveResource and transitive inheritance
  • From: Marcus Rueckert <darix@xxxxxxxxx>
  • Date: Mon, 21 Dec 2009 16:48:02 +0100
  • Message-id: <20091221154802.GD17200@xxxxxxxxxxxx>
On 2009-12-21 16:33:43 +0100, Duncan Mac-Vicar Prett wrote:
Date: Mon, 21 Dec 2009 16:33:43 +0100
From: Duncan Mac-Vicar Prett <dmacvicar@xxxxxxx>
Subject: Re: [opensuse-ruby] HelpNeeded: ActiveResource and transitive
inheritance
To: opensuse-ruby@xxxxxxxxxxxx
Cc: Josef Reidinger <jreidinger@xxxxxxx>

On Monday 21 December 2009 15:01:09 Josef Reidinger wrote:
from my understanding attr_accessor_with_default sets a instance variable
on the class object. those are not inherited.

class TestA
class << self
def test_a
"test_a"
end
end
end

class TestB < TestA
end

class TestC
class << self
attr_accessor_with_default(:test_c) { "test_c" }
end
end

class TestD < TestC
end

class TestF < TestD
end


puts TestA.test_a
puts TestB.test_a
puts TestC.test_c
puts TestD.test_c
puts TestF.test_c

output:
test_a
test_a
test_c
test_c
test_c

well i believe you that printing out the default value works, as it
should. but setting the value for test_c saves the value in an
*instance* variable of the Class object. :)

darix

--
openSUSE - SUSE Linux is my linux
openSUSE is good for you
www.opensuse.org
--
To unsubscribe, e-mail: opensuse-ruby+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-ruby+help@xxxxxxxxxxxx

< Previous Next >
List Navigation