Sha256: f9b2e2b88019257ba7a0b46432d7372e121612161a502ad0bc1e303526362395

Contents?: true

Size: 704 Bytes

Versions: 12

Compression:

Stored size: 704 Bytes

Contents

<%-
import converter_package

model = type.map[:model].type
gen_type = type.map[:gen_type].type
mappings = type.memo['mappings'] || []
requires_context = mappings.any?(&:requires_context)
arg_def_prefix = requires_context ? 'ctx context.Context, ' : nil
arg_prefix = requires_context ? 'ctx, ' : nil
-%>

func <%= gen_type.name %>ToModel(<%= arg_def_prefix %>payload *<%= gen_type.qualified_name(dependencies) %>) (*<%= model.qualified_name %>, error) {
	if payload == nil {
		return nil, <%= converter_package.name %>.NoPayloadGiven
	}
  var m <%= model.qualified_name %>
  if err := <%= gen_type.name %>AssignModel(<%= arg_prefix %>payload, &m); err != nil {
    return nil, err
  }
  return &m, nil
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
goon_model_gen-0.4.3 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.4.2 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.4.1 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.4.0 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.3.1 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.3.0 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.5 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.4 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.3 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.2 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.1 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb
goon_model_gen-0.2.0 lib/goon_model_gen/templates/converter/payload/03_ToModel.go.erb