0
我正在尋找一個ruby類,它可以在讀取mySQL數據庫中表的定義後生成Ramaze的續集模型文件。 例如,我想鍵入: ruby mySuperGenerator.rb "mytable"
是否存在續集模型生成器?
而結果應和在「模型」目錄中的文件「mytable.rb」,包含:
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
是否有人知道,如果這種發電機存在嗎?