Ruby - alias for object class -
sorry english.
my code ...
class myclass newfood = food def index @items = newfood.all end end
@items.first
food object, want newfood object
some help?
take example:
class foo @@instances = [] def initialize(value) @value = value @@instances << self end def self.all @@instances end end class bar newfoo = foo.dup def index @items = newfoo.all end end # bar::newfoo instantiate it's own objects bar::newfoo.new(5) bar::newfoo.new('fish') bar.new.index => [#<bar::newfoo:0x00000002f33cf0 @value=5>, #<bar::newfoo:0x00000002f65958 @value="fish">]
however fail see need kind of metaprogramming hack.
edit: crap, forgot class variables (@@var
) shared along it's childs, example turn messy.
Comments
Post a Comment