Sha256: 8cd6dd990a081adc63b97ecc8fdcf56966038294ea904b531a4cd55051224b37

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

class ProtobufDescriptor
  # A mixin module that adds tasty fully qualified name methods to objects that
  # have a name and a parent.
  #
  # Classes including this module *must* respond_to `name` and `parent`
  module NamedChild
    def fully_qualified_name
      return "#{parent.fully_qualified_name}.#{self.name}"
    end

    def fully_qualified_java_name
      return "#{parent.fully_qualified_java_name}.#{self.name}"
    end

    def fully_qualified_wire_name
      return "#{parent.fully_qualified_wire_name}.#{self.name}"
    end

    def fully_qualified_ruby_name
      return "#{parent.fully_qualified_ruby_name}::#{self.name}"
    end

    def inspect
      oid = (object_id << 1)
      return "#<%s:0x%x %s>" % [self.class, oid, self.fully_qualified_name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
protobuf_descriptor-1.1.1 lib/protobuf_descriptor/named_child.rb
protobuf_descriptor-1.1.0 lib/protobuf_descriptor/named_child.rb