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 14:57:32 +0100
  • Message-id: <20091221135732.GB17200@xxxxxxxxxxxx>
On 2009-12-21 08:40:58 +0100, Josef Reidinger wrote:
Hi, I create own wrapper over ActiveResource and found quite
interesting problem which blocking my work. If I create ancestor of
ActiveResource::Base then everything works, but when I create ancestor
of ancestor then it stop working (exactly it return nil on method
which should not return nil, because it is accessor with default and I
assign value so it should return assigned value or default but not
nil). I attach example code which demonstrate this problem.

your example and the active_resource code are not the same

[[[
require 'rubygems'
require 'active_resource'

class A
class << self
attr_accessor_with_default(:a) {
ActiveSupport::Inflector.pluralize(element_name) }
end
end

class B < A
end
class C < B
end

A.a = 'test'

puts A.a
puts B.a
puts C.a
]]]

from my understanding attr_accessor_with_default sets a instance variable on
the class object.
those are not inherited.

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
Follow Ups
References