Class: DatashiftJourney::ViewsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/datashift_journey/views_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_form_per_stateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/datashift_journey/views_generator.rb', line 9

def create_form_per_state
  method_ptr = if DatashiftJourney.journey_plan_class == DatashiftJourney::Collector::Collector
          ->(p) { view_for_collector_definition(p) }
        else
          ->(p) { view_for_journey_plan_definition(p) }
        end

  partial_location = DatashiftJourney::Configuration.call.partial_location

  path = 'app/views'
  path = File.join(path, partial_location) if partial_location.present?

  DatashiftJourney.state_names.each { |state| method_ptr.call(state.to_s, File.join(path, "_#{state}.html.erb")) }
end