Class: Schedulable::Generators::OccurrenceGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



14
15
16
# File 'lib/generators/schedulable/occurrence_generator.rb', line 14

def self.next_migration_number(path)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_migrationsObject



18
19
20
21
22
# File 'lib/generators/schedulable/occurrence_generator.rb', line 18

def create_migrations
  puts 'create schedulable occurrence model'
  migration_template 'migrations/create_occurrences.erb', "db/migrate/create_#{name.tableize}.rb", {name: self.name, attributes: self.attributes}
  template 'models/occurrence.erb', "app/models/#{name.tableize.singularize}.rb", {name: self.name, attributes: self.attributes}
end