Class: Trestle::Auth::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Trestle::Auth::Generators::InstallGenerator
- Defined in:
- lib/generators/trestle/auth/install/install_generator.rb
Instance Method Summary collapse
- #check_trestle_installed ⇒ Object
- #configuration_template ⇒ Object
- #devise? ⇒ Boolean
- #generate_account ⇒ Object
- #generate_admin ⇒ Object
- #generate_model ⇒ Object
- #insert_configuration ⇒ Object
Instance Method Details
#check_trestle_installed ⇒ Object
14 15 16 17 18 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 14 def check_trestle_installed unless ::File.exist?("config/initializers/trestle.rb") raise Thor::Error, "The file config/initializers/trestle.rb does not appear to exist. Please run `trestle:install` first." end end |
#configuration_template ⇒ Object
42 43 44 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 42 def configuration_template devise? ? "devise.rb.erb" : "basic.rb.erb" end |
#devise? ⇒ Boolean
38 39 40 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 38 def devise? [:devise] end |
#generate_account ⇒ Object
34 35 36 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 34 def generate_account generate "trestle:auth:account", model, ("--devise" if devise?) unless [:skip_account] end |
#generate_admin ⇒ Object
30 31 32 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 30 def generate_admin generate "trestle:auth:admin", model, ("--devise" if devise?) end |
#generate_model ⇒ Object
26 27 28 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 26 def generate_model generate "trestle:auth:model", model unless devise? end |
#insert_configuration ⇒ Object
20 21 22 23 24 |
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 20 def insert_configuration inject_into_file "config/initializers/trestle.rb", before: /^end/ do format_configuration(template_content(configuration_template)) end end |