Class: RollupsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RollupsGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/rollups_generator.rb
Overview
use rollups instead of rollup:install to avoid class Rollup < ActiveRecord::Base also works out nicely since it’s the gem name
Instance Method Summary collapse
Instance Method Details
#adapter ⇒ Object
27 28 29 |
# File 'lib/generators/rollups_generator.rb', line 27 def adapter ActiveRecord::Base.connection_db_config.adapter.to_s end |
#copy_templates ⇒ Object
10 11 12 |
# File 'lib/generators/rollups_generator.rb', line 10 def copy_templates migration_template migration_source, "db/migrate/create_rollups.rb", migration_version: migration_version end |
#migration_source ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/generators/rollups_generator.rb', line 14 def migration_source case adapter when /postg/i "dimensions.rb" else "standard.rb" end end |
#migration_version ⇒ Object
23 24 25 |
# File 'lib/generators/rollups_generator.rb', line 23 def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end |