Sha256: 22965835f2aa764b2ed06b2a05003948280a597a651cf50ea1674f7b4712c3f6
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
# coding: utf-8 require 'goa_model_gen' require "active_support/core_ext/string" module GoaModelGen class GoStruct attr_reader :name, :pkg_path, :size, :fields def initialize(d) @name = d['Name'] @pkg_path = d['PkgPath'] @size = d['Size'] @fields = (d['Fields'] || []).map do |f| GoStructField.new(f) end end end class GoStructField attr_reader :name, :type, :anonymous, :tags def initialize(d) @name = d['Name'] @anonymous = d['Anonymous'] @type = GoStructFieldType.new(d['Type']) @tags = d['Tag'] || {} end end class GoStructFieldType attr_reader :name, :kinds, :pkg_path, :representation def initialize(d) @name = d['Name'] @kinds = d['Kinds'] @pkg_path = d['PkgPath'] @representation = d['Representation'] end def ==(other) (pkg_path == other.pkg_path) && (name == other.name) && (kinds == other.kinds) && (representation == other.representation) end alias_method :assignable_with?, :== def pointer_of?(other) (pkg_path == other.pkg_path) && (name == other.name) && (kinds == (other.kinds + ['ptr'])) end def pointee_of?(other) other.pointer_of?(self) end def needs_error_to_convert_to?(other) return false if other.name == 'string' return true if name == 'string' return false end def method_part_name parts = kinds.first == 'struct' ? [name] + kinds[1..-1] : kinds parts.map(&:camelize).join end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
goa_model_gen-0.8.2 | lib/goa_model_gen/go_struct.rb |
goa_model_gen-0.8.1 | lib/goa_model_gen/go_struct.rb |
goa_model_gen-0.8.0 | lib/goa_model_gen/go_struct.rb |