Class: GoonModelGen::Golang::Struct

Inherits:
Type
  • Object
show all
Defined in:
lib/goon_model_gen/golang/struct.rb

Instance Attribute Summary collapse

Attributes inherited from Type

#name, #package

Instance Method Summary collapse

Methods inherited from Type

#initialize, #memo, #qualified_name

Constructor Details

This class inherits a constructor from GoonModelGen::Golang::Type

Instance Attribute Details

#ref_nameObject

Returns the value of attribute ref_name.



9
10
11
# File 'lib/goon_model_gen/golang/struct.rb', line 9

def ref_name
  @ref_name
end

Instance Method Details

#fieldsObject



11
12
13
# File 'lib/goon_model_gen/golang/struct.rb', line 11

def fields
  @fields ||= []
end

#id_fieldObject



25
26
27
# File 'lib/goon_model_gen/golang/struct.rb', line 25

def id_field
  fields.detect(&:goon_id)
end

#new_field(name, t, tags, options = {}) ⇒ Object

Parameters:

  • name (String)
  • t (String)
  • tags (Hash<String,Array<String>>)


18
19
20
21
22
23
# File 'lib/goon_model_gen/golang/struct.rb', line 18

def new_field(name, t, tags, options = {})
  Field.new(name, t, tags, options).tap do |f|
    f.struct = self
    fields.push(f)
  end
end

#resolve(pkgs) ⇒ Object

Parameters:



30
31
32
33
34
# File 'lib/goon_model_gen/golang/struct.rb', line 30

def resolve(pkgs)
  fields.each do |f|
    f.resolve(pkgs)
  end
end