Class: GoaModelGen::GoStructFieldType

Inherits:
Object
  • Object
show all
Defined in:
lib/goa_model_gen/go_struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(d) ⇒ GoStructFieldType

Returns a new instance of GoStructFieldType.



31
32
33
34
35
36
# File 'lib/goa_model_gen/go_struct.rb', line 31

def initialize(d)
  @name = d['Name']
  @kinds = d['Kinds']
  @pkg_path = d['PkgPath']
  @representation = d['Representation']
end

Instance Attribute Details

#kindsObject (readonly)

Returns the value of attribute kinds.



30
31
32
# File 'lib/goa_model_gen/go_struct.rb', line 30

def kinds
  @kinds
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/goa_model_gen/go_struct.rb', line 30

def name
  @name
end

#pkg_pathObject (readonly)

Returns the value of attribute pkg_path.



30
31
32
# File 'lib/goa_model_gen/go_struct.rb', line 30

def pkg_path
  @pkg_path
end

#representationObject (readonly)

Returns the value of attribute representation.



30
31
32
# File 'lib/goa_model_gen/go_struct.rb', line 30

def representation
  @representation
end

Instance Method Details

#==(other) ⇒ Object Also known as: assignable_with?



38
39
40
41
42
43
# File 'lib/goa_model_gen/go_struct.rb', line 38

def ==(other)
  (pkg_path == other.pkg_path) &&
    (name == other.name) &&
    (kinds == other.kinds) &&
    (representation == other.representation)
end

#method_part_nameObject



61
62
63
64
65
66
# File 'lib/goa_model_gen/go_struct.rb', line 61

def method_part_name
  parts =
    kinds.first == 'struct' ?
      [name] + kinds[1..-1] : kinds
  parts.map(&:camelize).join
end

#needs_error_to_convert_to?(other) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
# File 'lib/goa_model_gen/go_struct.rb', line 55

def needs_error_to_convert_to?(other)
  return false if other.name == 'string'
  return true if name == 'string'
  return false
end

#pointee_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/goa_model_gen/go_struct.rb', line 51

def pointee_of?(other)
  other.pointer_of?(self)
end

#pointer_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/goa_model_gen/go_struct.rb', line 46

def pointer_of?(other)
  (pkg_path == other.pkg_path) &&
    (name == other.name) &&
    (kinds == (other.kinds + ['ptr']))
end