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?)
- #defined_in_model? ⇒ Boolean
-
#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? ⇒ Boolean
- #pointer_of?(other) ⇒ Boolean
Constructor Details
#initialize(d) ⇒ GoStructFieldType
Returns a new instance of GoStructFieldType.
35 36 37 38 39 40 |
# File 'lib/goa_model_gen/go_struct.rb', line 35 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.
34 35 36 |
# File 'lib/goa_model_gen/go_struct.rb', line 34 def kinds @kinds end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/goa_model_gen/go_struct.rb', line 34 def name @name end |
#pkg_path ⇒ Object (readonly)
Returns the value of attribute pkg_path.
34 35 36 |
# File 'lib/goa_model_gen/go_struct.rb', line 34 def pkg_path @pkg_path end |
#representation ⇒ Object (readonly)
Returns the value of attribute representation.
34 35 36 |
# File 'lib/goa_model_gen/go_struct.rb', line 34 def representation @representation end |
Instance Method Details
#==(other) ⇒ Object Also known as: assignable_with?
42 43 44 45 46 47 |
# File 'lib/goa_model_gen/go_struct.rb', line 42 def ==(other) (pkg_path == other.pkg_path) && (name == other.name) && (kinds == other.kinds) && (representation == other.representation) end |
#defined_in_model? ⇒ Boolean
77 78 79 |
# File 'lib/goa_model_gen/go_struct.rb', line 77 def defined_in_model? pkg_path =~ /\/model\z/ end |
#method_part_name ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/goa_model_gen/go_struct.rb', line 68 def method_part_name parts = kinds.dup parts.pop if parts.last == 'ptr' parts = (parts.first == 'struct' || pkg_path.present?) ? [name] + parts[1..-1] : parts parts.map(&:camelize).join end |
#needs_error_to_convert_to?(other) ⇒ Boolean
62 63 64 65 66 |
# File 'lib/goa_model_gen/go_struct.rb', line 62 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
58 59 60 |
# File 'lib/goa_model_gen/go_struct.rb', line 58 def pointee_of?(other) other.pointer_of?(self) end |
#pointer? ⇒ Boolean
50 51 52 |
# File 'lib/goa_model_gen/go_struct.rb', line 50 def pointer? kinds.last == 'ptr' end |
#pointer_of?(other) ⇒ Boolean
53 54 55 56 57 |
# File 'lib/goa_model_gen/go_struct.rb', line 53 def pointer_of?(other) (pkg_path == other.pkg_path) && (name == other.name) && (kinds == (other.kinds + ['ptr'])) end |