Ich bin auf der Suche nach einer Ruby-Klasse, die die Fortsetzung Modell-Datei für Ramaze nach dem Lesen der Definition der Tabelle in einer MySQL-Datenbank generieren könnte. Zum Beispiel würde ich geben mag: ruby mySuperGenerator.rb "mytable"
existiert ein Nachfolgermodell-Generator?
Und das Ergebnis shold die Datei „mytable.rb“ in „Modell“ Verzeichnis sein, mit:
class Mytable < Sequel::Model(:mytable)
# All plugins I've defined somewhere before lauching the generator
plugin :validation_helpers
plugin :json_serializer
one_to_many :othertable
many_to_one :othertable2
def validate
# Generating this if there are some not null attributes in this table
validates_presence [:fieldthatshoulnotbenull1, :fieldthatshoulnotbenull2]
errors.add(:fieldthatshoulnotbenull1, 'The field fieldthatshoulnotbenull1 should not be null.') if self.fieldthatshoulnotbenull1.nil?
end
def before_create
# All the default values found for each table attributes
self.creation_time ||= Time.now
end
def before_destroy
# referential integrity
self.othertable_dataset.destroy unless self.othertable.nil?
end
end
jemand Hat weiß, ob ein solcher Generator existiert?