Class: Blueprints::ModelGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Blueprints::ModelGenerator
- Defined in:
- lib/generators/blueprints/model/model_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_blueprint ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/blueprints/model/model_generator.rb', line 5 def create_blueprint blueprint = "#{class_name}.blueprint :#{singular_name}" attributes.each do |attribute| blueprint << ", :#{attribute.name} => #{default_for(attribute)}" end dir = File.exists?('spec') ? 'spec' : 'test' file = "#{dir}/blueprint.rb" create_file file unless File.exists?(file) append_file file, "#{blueprint}\n" end |