Class: Draft::AccountGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Draft::AccountGenerator
- Includes:
- Rails::Generators::ResourceHelpers
- Defined in:
- lib/generators/draft/account/account_generator.rb
Instance Method Summary collapse
- #create_root_folder ⇒ Object
- #generate_before_actions ⇒ Object
- #generate_controller ⇒ Object
- #generate_model ⇒ Object
- #generate_required_attributes ⇒ Object
- #generate_routes ⇒ Object
- #generate_view_files ⇒ Object
Instance Method Details
#create_root_folder ⇒ Object
40 41 42 |
# File 'lib/generators/draft/account/account_generator.rb', line 40 def create_root_folder empty_directory File.join("app/views", "#{singular_table_name.underscore}_authentication") end |
#generate_before_actions ⇒ Object
32 33 34 |
# File 'lib/generators/draft/account/account_generator.rb', line 32 def generate_before_actions authentication_helpers end |
#generate_controller ⇒ Object
36 37 38 |
# File 'lib/generators/draft/account/account_generator.rb', line 36 def generate_controller template "controllers/authentication_controller.rb", "app/controllers/#{singular_table_name.underscore}_authentication_controller.rb" end |
#generate_model ⇒ Object
23 24 25 26 |
# File 'lib/generators/draft/account/account_generator.rb', line 23 def generate_model invoke "draft:model", paramaterize_attributes edit_model end |
#generate_required_attributes ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/draft/account/account_generator.rb', line 12 def generate_required_attributes unless attributes_has_password_digest? password_digest = Rails::Generators::GeneratedAttribute.parse(["password_digest", :string, nil].compact.join(":")) attributes.unshift(password_digest) end unless attributes_has_email? email = Rails::Generators::GeneratedAttribute.parse(["email", :string, nil].compact.join(":")) attributes.unshift(email) end end |
#generate_routes ⇒ Object
28 29 30 |
# File 'lib/generators/draft/account/account_generator.rb', line 28 def generate_routes authentication_routes end |
#generate_view_files ⇒ Object
44 45 46 47 48 49 |
# File 'lib/generators/draft/account/account_generator.rb', line 44 def generate_view_files available_views.each do |view| filename = view_authentication_filename_with_extensions(view) template filename, File.join("app/views/#{singular_table_name.underscore}_authentication", File.basename(filename)) end end |