Class: Stager::ScaffoldGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/stager/scaffold/scaffold_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_controllerObject



38
39
40
# File 'lib/generators/stager/scaffold/scaffold_generator.rb', line 38

def create_controller
  invoke "stager:controller", [scaffold_name.pluralize, model_and_controller_args, option?(:namespaced_model), option?(:skip_views), option?(:skip_helper)]
end

#create_modelObject



32
33
34
35
36
# File 'lib/generators/stager/scaffold/scaffold_generator.rb', line 32

def create_model
  unless @skip_model
    invoke "stager:model", [namespaced_scaffold_name?, model_attributes, option?(:skip_migration), option?(:skip_timestamps)]
  end
end

#create_presenterObject



42
43
44
45
46
# File 'lib/generators/stager/scaffold/scaffold_generator.rb', line 42

def create_presenter
  unless options[:skip_presenter]
    invoke "exhibit:presenter", [scaffold_name, options[:namespaced_model] ? nil : "--no_namespace"]
  end
end

#set_optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/stager/scaffold/scaffold_generator.rb', line 16

def set_options
  @model_attributes = []
  @invert_actions = false
  @skip_model = false
  
  model_and_controller_args.each do |arg|
    if arg.include?(':')
      @model_attributes << arg
    end
  end
  
  if @model_attributes.empty?
    @skip_model = true
  end
end