Marcus Rueckert write:
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
Thanks, so it sets only to instance. I found that I cannot move all models which is based on out rest-service to ancestor, but use module, which sets it to class instance. Thanks for explanation. I add it to documentation why module instead of ancestor must be used. Josef -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast (language,time,basesystem,ntp) -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-ruby+help@opensuse.org