Class: Tennpipes::Generators::Model
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Tennpipes::Generators::Model
- Includes:
- Actions, Components::Actions, Thor::Actions
- Defined in:
- lib/tennpipes-init/generators/model.rb
Overview
Responsible for generating new models for the specified ORM component.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_model ⇒ Object
Execute the model generation.
Methods included from Components::Actions
#controller_actions, #create_helper_files, #current_migration_number, #indent_spaces, #insert_mocking_include, #insert_test_suite_setup, #migration_exist?, #output_migration_file, #output_model_migration, #remove_migration, #return_last_migration_number
Methods included from Actions
#already_exists?, #app_skeleton, #apply_component_for, #apply_default_fields, #ask, #check_app_existence, #destination_root, #empty_directory_with_keep_file, #execute_component_setup, #fetch_app_name, #fetch_component_choice, #fetch_project_name, #in_app_root?, #include_component_module_for, included, #initializer, #inject_into_file, #insert_hook, #insert_into_gemfile, #insert_middleware, #invalid_fields, #keep_file, #middleware, #recognize_path, #require_contrib, #require_dependencies, #resolve_valid_choice, #retrieve_component_config, #run_bundler, #store_component_choice, #store_component_config, #test?, #tiny?, #valid_choice?, #valid_constant?
Class Method Details
.banner ⇒ Object
10 |
# File 'lib/tennpipes-init/generators/model.rb', line 10 def self.; "tennpipes-init model [name] [fields]"; end |
.source_root ⇒ Object
9 |
# File 'lib/tennpipes-init/generators/model.rb', line 9 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#create_model ⇒ Object
Execute the model generation.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tennpipes-init/generators/model.rb', line 31 def create_model app = [:app] return unless valid_model_for?(app) include_component_module_for(:test) migration_name = "create_#{name.pluralize.underscore}" apply_default_fields fields create_model_file(name, :fields => fields, :app => app) generate_model_test(name) if test? create_model_migration(migration_name, name, fields) unless [:skip_migration] end |