Class: EventSourcedRecord::ProjectionGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- EventSourcedRecord::ProjectionGenerator
- Defined in:
- lib/generators/event_sourced_record/projection_generator.rb
Instance Method Summary collapse
Instance Method Details
#attributes_with_index ⇒ Object
30 31 32 |
# File 'lib/generators/event_sourced_record/projection_generator.rb', line 30 def attributes_with_index attributes.select { |a| a.has_index? || (a.reference? && [:indexes]) } end |
#create_migration_file ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/event_sourced_record/projection_generator.rb', line 8 def create_migration_file ar_major_version = ActiveRecord::VERSION::MAJOR if ar_major_version >= 4 generate( "migration", "create_#{projection_table_name} #{migration_attributes}" ) else migration_template( "projection_migration.ar3.rb", "db/migrate/create_#{projection_table_name}.rb" ) end end |
#create_model_file ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/generators/event_sourced_record/projection_generator.rb', line 22 def create_model_file ar_major_version = ActiveRecord::VERSION::MAJOR template( "projection_model.ar#{ar_major_version}.rb", File.join('app/models', class_path, "#{projection_file_name}.rb") ) end |