class Lit::Generators::InstallGenerator
Public Instance Methods
add_lit_initializer()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 37 def add_lit_initializer path = "#{::Rails.root}/config/initializers/lit.rb" if File.exist?(path) puts 'Skipping config/initializers/lit.rb creation, file already exists!' else puts 'Adding lit initializer (config/initializers/lit.rb)...' template 'initializer.erb', path end end
add_redis_dependency()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 25 def add_redis_dependency if @key_value_engine == 'redis' puts 'Adding redis dependency' gem 'redis' Bundler.with_clean_env { run 'bundle install' } end end
clear_cache()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 54 def clear_cache Lit.init.cache.reset end
generate_api_key()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 33 def generate_api_key @api_key = SecureRandom.base64 32 end
mount_engine()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 58 def mount_engine puts "Mounting Lit::Engine at \"/lit\" in config/routes.rb..." route "mount Lit::Engine => '/lit'" end
run_migrations()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 47 def run_migrations unless options['no-migrate'] puts 'Running rake db:migrate' `rake db:migrate` end end
set_authentication_function()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 13 def set_authentication_function @authentication_function = options['authentication-function'].presence || ask("What's the authentication function, ie. :authenticate_user! :").presence || nil end
set_key_value_engine()
click to toggle source
# File lib/generators/lit/install_generator.rb, line 19 def set_key_value_engine @key_value_engine = options['key-value-engine'].presence || ask("What's the key value engine? ([hash] OR redis):").presence || :hash end