Class: Settings::InstallGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Settings::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/settings/install_generator.rb
Constant Summary collapse
- @@migrations =
false
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
:nodoc:
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/settings/install_generator.rb', line 15 def self.next_migration_number(dirname) #:nodoc: if ActiveRecord::Base. if @@migrations (current_migration_number(dirname) + 1) else @@migrations = true Time.now.utc.strftime("%Y%m%d%H%M%S") end else format "%.3d", current_migration_number(dirname) + 1 end end |
Instance Method Details
#install_setting ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/settings/install_generator.rb', line 28 def install_setting template "model.rb", File.join("app/models", class_path, "#{file_name}.rb") template "app.yml", File.join("config", "app.yml") migration_template "migration.rb", "db/migrate/create_settings.rb", migration_version: migration_version end |
#migration_version ⇒ Object
38 39 40 |
# File 'lib/generators/settings/install_generator.rb', line 38 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5? end |
#rails5? ⇒ Boolean
34 35 36 |
# File 'lib/generators/settings/install_generator.rb', line 34 def rails5? Rails.version.start_with? "5" end |