Class: Trestle::Auth::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#check_trestle_installedObject



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_templateObject



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

Returns:

  • (Boolean)


38
39
40
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 38

def devise?
  options[:devise]
end

#generate_accountObject



34
35
36
# File 'lib/generators/trestle/auth/install/install_generator.rb', line 34

def 
  generate "trestle:auth:account", model, ("--devise" if devise?) unless options[:skip_account]
end

#generate_adminObject



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_modelObject



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_configurationObject



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