Class: Rubyblok::Generators::ImageCacheGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/rubyblok/image_cache_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



26
27
28
# File 'lib/generators/rubyblok/image_cache_generator.rb', line 26

def self.next_migration_number(dirname)
  ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#installObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/rubyblok/image_cache_generator.rb', line 13

def install
  if table_exist?
    migration_template('migration_update_image_cache.rb.erb', "db/migrate/update_#{plural_file_name}.rb",
                       migration_version:)
  else
    migration_template('migration_create_image_cache.rb.erb', "db/migrate/create_#{plural_file_name}.rb",
                       migration_version:)
  end

  create_or_update_model
  add_model_name_to_config
end