Sha256: 7afcfca4a535f3d8069d96c7720737f4bd2c98420af874c34e3898b9a0ded054

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

class ScaffoldGenerator < VraptorScaffold::Base

  attr_accessor :generated_attributes
  argument :model
  argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type"


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

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vraptor-scaffold-1.3.0 lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb
vraptor-scaffold-1.3.0.rc lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb