Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (31 sloc) 1021 Bytes
class ModelGenerator < Merb::GeneratorBase
attr_reader :model_attributes, :model_class_name, :model_file_name
def initialize(args, runtime_args = {})
@base = File.dirname(__FILE__)
super
class_name = args.shift.snake_case.to_const_string
@model_file_name = class_name
@model_class_name = class_name
@model_attributes = Hash[*(args.map{|a| a.split(":") }.flatten)]
@model_file_name = "#{@model_class_name}"
end
def manifest
record do |m|
@m = m
@assigns = { :model_file_name => model_file_name,
:model_attributes => model_attributes,
:model_class_name => model_class_name
}
copy_dirs
copy_files
m.dependency "merb_model_test", [model_file_name], @assigns
end
end
protected
def banner
<<-EOS.split("\n").map{|x| x.strip}.join("\n")
Creates a RDb4o Model stub..
USAGE: #{spec.name}"
EOS
end
end