Class: Boring::Flipper::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boring/flipper/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_flipper_gemObject



9
10
11
12
13
14
# File 'lib/generators/boring/flipper/install/install_generator.rb', line 9

def add_flipper_gem
  say "Adding Flipper gem", :green
  Bundler.with_unbundled_env do
    run "bundle add flipper-active_record flipper-ui"
  end
end

#add_flipper_initializerObject



24
25
26
27
# File 'lib/generators/boring/flipper/install/install_generator.rb', line 24

def add_flipper_initializer
  say "Adding Flipper initializer", :green
  copy_file "initializer.rb", "config/initializers/flipper.rb"
end

#add_flipper_routesObject



29
30
31
32
33
34
# File 'lib/generators/boring/flipper/install/install_generator.rb', line 29

def add_flipper_routes
  say "Adding Flipper UI routes", :green
  route <<~ROUTE
    mount Flipper::UI.app(Flipper) => '/admins/flipper'
  ROUTE
end

#run_flipper_active_record_generatorObject



16
17
18
19
20
21
22
# File 'lib/generators/boring/flipper/install/install_generator.rb', line 16

def run_flipper_active_record_generator
  say "Running Active Record Flipper generator", :green
  Bundler.with_unbundled_env do
    run "bundle exec rails generate flipper:active_record"
    run "bundle exec rails db:migrate"
  end
end