Class: ScaffoldGenerator

Inherits:
VraptorScaffold::Base show all
Defined in:
lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ScaffoldGenerator



12
13
14
15
16
17
18
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 12

def initialize(args)
  super(args)
  @generated_attributes = []
  attributes.each { |field, type| 
    @generated_attributes << Attribute.new(field, type)
  }
end

Instance Attribute Details

#generated_attributesObject

Returns the value of attribute generated_attributes



3
4
5
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 3

def generated_attributes
  @generated_attributes
end

Class Method Details



8
9
10
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 8

def self.banner
  "vraptor scaffold #{self.arguments.map(&:usage).join(' ')}"
end

Instance Method Details

#controller_generatorObject



20
21
22
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 20

def controller_generator
  ControllerGenerator.new(model, @generated_attributes).build
end

#model_generatorObject



24
25
26
27
28
29
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 24

def model_generator
  models_generator_available = {"jpa" => ModelGenerator,
                                "hibernate" => ModelGenerator,
                                "objectify" => ObjectifyModelGenerator }
  models_generator_available.fetch(Configuration.orm).new(model, @generated_attributes).build
end

#repository_generatorObject



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

def repository_generator
  repository_generators_available = {"jpa" => RepositoryGenerator,
                                     "hibernate" => RepositoryGenerator,
                                     "objectify" => ObjectifyRepositoryGenerator }
  repository_generators_available.fetch(Configuration.orm).new(model, @generated_attributes).build
end

#template_engine_generatorObject



38
39
40
41
# File 'lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb', line 38

def template_engine_generator
  templates = {"jsp" => JspGenerator, "ftl" => FreemarkerGenerator}
  templates[Configuration.template_engine].new(model, @generated_attributes).build
end