Class: RlsMultiTenant::Generators::ModelGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RlsMultiTenant::Generators::ModelGenerator
- Defined in:
- lib/rls_multi_tenant/generators/model/model_generator.rb
Instance Method Summary collapse
- #create_migration ⇒ Object
- #create_model_file ⇒ Object
-
#initialize(args, *options) ⇒ ModelGenerator
constructor
A new instance of ModelGenerator.
- #show_instructions ⇒ Object
Constructor Details
#initialize(args, *options) ⇒ ModelGenerator
Returns a new instance of ModelGenerator.
13 14 15 16 |
# File 'lib/rls_multi_tenant/generators/model/model_generator.rb', line 13 def initialize(args, *) super @attributes = parse_attributes! end |
Instance Method Details
#create_migration ⇒ Object
24 25 26 |
# File 'lib/rls_multi_tenant/generators/model/model_generator.rb', line 24 def create_migration template 'migration.rb', File.join('db/migrate', "#{migration_file_name}.rb") end |
#create_model_file ⇒ Object
20 21 22 |
# File 'lib/rls_multi_tenant/generators/model/model_generator.rb', line 20 def create_model_file template 'model.rb', File.join('app/models', "#{model_name.underscore}.rb") end |
#show_instructions ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rls_multi_tenant/generators/model/model_generator.rb', line 28 def show_instructions say "\n#{'=' * 60}", :green say "Multi-tenant model '#{model_name}' created successfully!", :green say '=' * 60, :green say "\nWhat was created:", :yellow say "1. Model: app/models/#{model_name.underscore}.rb (with MultiTenant concern included)", :yellow say "2. Migration: #{migration_file_name}.rb (with RLS policies)", :yellow say '=' * 60, :green end |