Class: Disco::Generators::AppGenerator

Inherits:
Rails::Generators::AppGenerator
  • Object
show all
Defined in:
lib/disco/commands/application.rb,
lib/generators/disco/app/app_generator.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

We want to exit on failure to be kind to other libraries This is only when accessing via CLI

Returns:

  • (Boolean)


36
37
38
# File 'lib/disco/commands/application.rb', line 36

def self.exit_on_failure?
  true
end

Instance Method Details

#add_event_source_routeObject



76
77
78
79
# File 'lib/generators/disco/app/app_generator.rb', line 76

def add_event_source_route
  return if behavior == :revoke
  route "get 'event_source/:projection/:event' => 'event_source#projected', as: 'event_source'"
end

#enable_concurrencyObject



92
93
94
95
96
97
98
99
100
101
# File 'lib/generators/disco/app/app_generator.rb', line 92

def enable_concurrency
  return if behavior == :revoke
  application 'config.preload_frameworks = true'
  application 'config.allow_concurrency = true'
rescue Exception
  puts "Seems like you invoked it from an engine, so remember to put\n
  config.preload_frameworks = true
  config.allow_concurrency = true\n
  in your application.rb from the main application"
end

#enable_rake_tasksObject



81
82
83
84
85
86
87
88
89
90
# File 'lib/generators/disco/app/app_generator.rb', line 81

def enable_rake_tasks
  return if behavior == :revoke
  content = "
require 'rails-disco/tasks'"
  inject_into_file File.join('config/application.rb'), content, after: /require 'rails\/all'/
rescue Exception
  puts "Seems like you invoked it from an engine, so put\n
  require 'rails-disco/tasks'\n
  in your application.rb from the main application to have the rails disco rake tasks available"
end

#source_pathsObject



72
73
74
# File 'lib/generators/disco/app/app_generator.rb', line 72

def source_paths
  [File.join(Gem::Specification.find_by_name('railties').gem_dir, 'lib/rails/generators/rails/app/templates'), File.expand_path('../templates', __FILE__)]
end