Class: GoaModelGen::GoStructFieldType
- Inherits:
-
Object
- Object
- GoaModelGen::GoStructFieldType
- Defined in:
- lib/goa_model_gen/go_struct.rb
Instance Attribute Summary collapse
-
#kinds ⇒ Object
readonly
Returns the value of attribute kinds.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pkg_path ⇒ Object
readonly
Returns the value of attribute pkg_path.
-
#representation ⇒ Object
readonly
Returns the value of attribute representation.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #assignable_with?)
-
#initialize(d) ⇒ GoStructFieldType
constructor
A new instance of GoStructFieldType.
- #method_part_name ⇒ Object
- #needs_error_to_convert_to?(other) ⇒ Boolean
- #pointee_of?(other) ⇒ Boolean
- #pointer_of?(other) ⇒ Boolean
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
#kinds ⇒ Object (readonly)
Returns the value of attribute kinds.
30 31 32 |
# File 'lib/goa_model_gen/go_struct.rb', line 30 def kinds @kinds end |
#name ⇒ Object (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_path ⇒ Object (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 |
#representation ⇒ Object (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_name ⇒ Object
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
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
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
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 |