Class: EventSourcedRecord::EventSourcedRecordGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- EventSourcedRecord::EventSourcedRecordGenerator
- Defined in:
- lib/generators/event_sourced_record/event_sourced_record_generator.rb
Instance Method Summary collapse
- #create_calculator_class ⇒ Object
- #create_event ⇒ Object
- #create_observer ⇒ Object
- #create_projection ⇒ Object
- #create_rake_file ⇒ Object
Instance Method Details
#create_calculator_class ⇒ Object
9 10 11 |
# File 'lib/generators/event_sourced_record/event_sourced_record_generator.rb', line 9 def create_calculator_class generate "event_sourced_record:calculator", "#{file_name}_calculator" end |
#create_event ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/generators/event_sourced_record/event_sourced_record_generator.rb', line 13 def create_event arguments = [ "#{file_name}_uuid:string:index", "event_type:string", "data:text", "created_at:datetime", "occurred_at:datetime" ].join(' ') generate "event_sourced_record:event", "#{file_name}_event #{arguments}" end |
#create_observer ⇒ Object
21 22 23 |
# File 'lib/generators/event_sourced_record/event_sourced_record_generator.rb', line 21 def create_observer generate "event_sourced_record:observer", "#{file_name}_event_observer" end |
#create_projection ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/event_sourced_record/event_sourced_record_generator.rb', line 25 def create_projection attr_strings = attributes.map { |attr| attr_string = attr.name attr_string << ":#{attr.type}" if attr.type attr_string << ':index' if attr.has_index? attr_string } projection_attributes = attr_strings.join(' ') generate "event_sourced_record:projection", "#{file_name} #{projection_attributes}" end |
#create_rake_file ⇒ Object
36 37 38 39 40 41 |
# File 'lib/generators/event_sourced_record/event_sourced_record_generator.rb', line 36 def create_rake_file template( "event_sourced_record.rake", File.join("lib/tasks", class_path, "#{file_name}.rake") ) end |