Class: ReativoGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/reativo/reativo_generator.rb

Constant Summary collapse

MAP =
{
  index:   { operation: true, contract: false, representer: true},
  create:  { operation: true, contract: true,  representer: true},
  show:    { operation: true, contract: false, representer: false},
  update:  { operation: true, contract: true,  representer: true},
  destroy: { operation: true, contract: false, representer: false},
}

Instance Method Summary collapse

Instance Method Details

#generate_operationsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/reativo/reativo_generator.rb', line 17

def generate_operations
  representer_module = false
  actions = options['actions'] || []

  actions = ['index', 'create', 'show', 'update', 'destroy'] if options[:crud]

  actions.each do |action|
    template "operation/#{action}.erb", concept_path("operation", action) if has_operation?(action)
    template "contract/#{action}.erb", concept_path("contract", action) if has_contract?(action)
    if has_representer?(action)
      template "representer/#{action}.erb", concept_path("representer", action)
      representer_module = true
    end
  end

  if representer_module
    template "representer/module.erb", concept_path("representer", "#{model_name.underscore}_module")
  end
end