Class: JayZ::Generators::ModelGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/jay_z/model/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_blueprintObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/jay_z/model/model_generator.rb', line 6

def create_blueprint
  file_name = if File.exists?(File.join(Rails.root, 'test', 'blueprint.rb'))
    "test/blueprint.rb"
  elsif File.exists?(File.join(Rails.root, 'spec', 'blueprint.rb'))
    "spec/blueprint.rb"
  else
    raise "Cannot find the blueprint file"
  end
  gsub_file(file_name, /.end\s*\Z/mx) { |match| "#{code}\n#{match}" }
end