Class: Streamline::Generators::Stores::ActiveRecordGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Streamline::Generators::Stores::ActiveRecordGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/streamline/stores/active_record_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number ⇒ Object
9 10 11 |
# File 'lib/generators/streamline/stores/active_record_generator.rb', line 9 def self.next_migration_number(*) Time.now.utc.strftime('%Y%m%d%H%M%S') end |
Instance Method Details
#copy_migrations ⇒ Object
13 14 15 16 |
# File 'lib/generators/streamline/stores/active_record_generator.rb', line 13 def copy_migrations migration_template 'create_events.rb', 'db/migrate/create_streamline_events.rb' end |
#copy_models ⇒ Object
18 19 20 |
# File 'lib/generators/streamline/stores/active_record_generator.rb', line 18 def copy_models template 'event.rb', 'app/models/streamline/event.rb' end |
#jsonb? ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'lib/generators/streamline/stores/active_record_generator.rb', line 22 def jsonb? return false unless postgresql? ActiveRecord::Base .connection .execute('SELECT version();')[0]['version'] .start_with?('PostgreSQL 9.4') end |
#postgresql? ⇒ Boolean
31 32 33 34 |
# File 'lib/generators/streamline/stores/active_record_generator.rb', line 31 def postgresql? config = ActiveRecord::Base.configurations[Rails.env] config && config['adapter'] == 'postgresql' end |