On 2007-11-01, at 17:07, Moritz Heidkamp wrote:
Guten Tag,
Am Thu, 01 Nov 2007 16:59:39 +0100 schrieb Michael Kastner <[EMAIL PROTECTED]
>:
ich suche eine Methode, die mir angibt, ob ein Klassenattribut
vorhanden ist.
meinst du mit Klassenattribut vielleicht Klassenvariable? Dann hilft
dir defined?
Solltest du Attributaccessor einer Klasse meinen, einfach respond_to?
direkt aus der offiziellen doku:
1.
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables #=> ["@@var1"]
Two.class_variables #=> ["@@var2", "@@var1"]
2.
Returns the value of the given class variable (or throws a NameError
exception). The @@ part of the variable name should be included for
regular class variables
class Fred
@@foo = 99
end
def Fred.foo
class_variable_get(:@@foo) #=> 99
end
Eins davon wird dir sicher weiterhelfen ..
Gruss
Ben
---
Benjamin Krause
http://www.omdb.org/
[EMAIL PROTECTED]
Rails-Schulung "Advancing with Rails" mit David A. Black
19.11.-22.11.2007, Berlin-Mitte
Details u. Anmeldung: http://www.railsschulung.de
Learn more about Ferret and acts_as_ferret
http://www.heise.de/ix/inhalt.shtml
_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/mailman/listinfo/rubyonrails-ug