Class: Pgq::AddGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Pgq::AddGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/pgq/add_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(path) ⇒ Object
7 8 9 |
# File 'lib/generators/pgq/add_generator.rb', line 7 def self.next_migration_number(path) Time.now.utc.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#add_files ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/pgq/add_generator.rb', line 23 def add_files template "pgq_class.rb", "app/models/pgq/pgq_#{name}.rb" template "spec.rb", "spec/models/pgq/pgq_#{name}_spec.rb" migration_template "migration.rb", "db/migrate/create_#{name}_queue.rb" end |
#add_to_queues_list ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/pgq/add_generator.rb', line 11 def add_to_queues_list filename = Rails.root + 'config/queues_list.yml' if File.exists?(filename) x = YAML.load_file(filename) x << name File.open(filename, 'w'){|f| f.write(YAML.dump(x))} else x = [name] File.open(filename, 'w'){|f| f.write(YAML.dump(x))} end end |