class ShouldaMatchmakers::FactoryGenerator
Public Instance Methods
create_model_factories()
click to toggle source
# File lib/generators/shoulda_matchmakers/factory_generator.rb, line 53 def create_model_factories puts "\n" generator = "factory" generator_options = options.to_hash working_generated_code_line_length = ::ShouldaMatchmakers.configuration.preferred_generated_code_line_length - 6 SpinToWin.with_spinner('ShouldaMatchmakers:Factories') do |spinner| spinner.banner('initializing...') load_application @app_active_record_descendants_names = get_app_active_record_descendants_names end puts "\n" generate_active_record_model_factories(generator, generator_options, @app_active_record_descendants_names, working_generated_code_line_length) end
Private Instance Methods
generate_active_record_model_factories(generator, generator_options, app_active_record_descendants_names, code_line_length)
click to toggle source
# File lib/generators/shoulda_matchmakers/factory_generator.rb, line 70 def generate_active_record_model_factories(generator, generator_options, app_active_record_descendants_names, code_line_length) if app_active_record_descendants_names.present? selected_app_active_record_descendants_names = filter_app_active_record_descendants_names(generator, generator_options, app_active_record_descendants_names) selected_app_active_record_descendants_names.each do |app_class_name| save_generate(app_class_name, generator) do @active_record_model_factory_sm_model = ::ShouldaMatchmakers::Model::ActiveRecord::FactorySmModel.new(app_class_name, code_line_length) template_filename = File.expand_path('../../templates/factory/active_record/factory_template.haml', File.dirname(__FILE__)) template = File.read(template_filename) create_file "#{ ::ShouldaMatchmakers.configuration.active_record_model_factories_path }/#{ app_class_name.underscore }_factory.rb", Haml::Engine.new(template, filename: template_filename, format: :html5).to_html(binding) end end end end