Sha256: 8506c4a6fa026c3ec7c6e541049877de689c6258de6a9f9ef98621db0e7fc6e6

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

class DomainsGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)

  def create_initializer_file
    empty_directory "app/domains/#{file_name}"
    create_file "app/domains/#{file_name}/.keep"

    if File.exists? "config/application.rb"
      inject_into_file 'config/application.rb', :before => "  end\nend" do
        <<-"RUBY"

    # Configure load paths for DDD domain #{file_name}
    config.autoload_paths += %W(\#{config.root}/app/domains/#{file_name})
        RUBY
      end
    elsif File.exists? "lib/#{namespace.to_s.underscore}/engine.rb"
      inject_into_file "lib/#{namespace.to_s.underscore}/engine.rb", :before => "  end\nend" do
        <<-"RUBY"

    config.autoload_paths += %W(\#{config.root}/app/domains/#{file_name})
        RUBY
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddd_domain-1.0.0 lib/generators/domains/domains_generator.rb
ddd_domain-0.0.3 lib/generators/domains/domains_generator.rb