Class: GoonModelGen::Builder::ValidationBuilder

Inherits:
AbstractBuilder show all
Defined in:
lib/goon_model_gen/builder/validation_builder.rb

Instance Attribute Summary

Attributes inherited from AbstractBuilder

#base_package_path, #config, #package_suffix

Instance Method Summary collapse

Methods inherited from AbstractBuilder

#build_package, #build_sentences, #build_sentences_with, #method_to_template_for, #method_to_template_map, #templates_for

Constructor Details

#initialize(config) ⇒ ValidationBuilder

Returns a new instance of ValidationBuilder.

Parameters:



15
16
17
# File 'lib/goon_model_gen/builder/validation_builder.rb', line 15

def initialize(config)
  super(config, config.validation_package_path)
end

Instance Method Details

#buildGolang::Packages

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/goon_model_gen/builder/validation_builder.rb', line 20

def build(*)
  Golang::Packages.new.tap do |r|
    r.new_package(base_package_path).tap do |pkg|
      t = pkg.new_struct('ValidationError')
      pkg.new_file('validation_error.go').tap do |f|
        build_sentences_with('validation/error', t, nil)
      end
    end
  end
end

#resolve_type_names(pkgs) ⇒ Object

Parameters:



32
33
34
# File 'lib/goon_model_gen/builder/validation_builder.rb', line 32

def resolve_type_names(pkgs)
  pkgs.resolve_type_names(Golang::DatastorePackageFactory.new(config.package_alias_map).packages)
end