Sha256: f2c5e0ed31879afc6eda3267f97c05a4d4acc762d0ae32cfed5d05c39b6d3c97

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

class Protod
  module Proto
    class << self
      # https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md
      def omits_field?(pb, name)
        return false unless pb.respond_to?("has_#{name}?")
        return false if pb.public_send("has_#{name}?")
        true
      end
    end

    class Ident < ::String
      class << self
        def build_from(const_name)
          return if const_name.blank?

          new(const_name)
        end
      end

      attr_reader :const_name

      def initialize(const_name)
        @const_name = Protod::RubyIdent.absolute_of(const_name)

        super(const_name.gsub('::', '__').delete_prefix('__'))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protod-0.1.0 lib/protod/proto/features.rb