Sha256: 8c4f3c01ee11bfb8666766fe6aef02d229022d9450117840c57824f79e6fab23
Contents?: true
Size: 655 Bytes
Versions: 99
Compression:
Stored size: 655 Bytes
Contents
require 'protobuf/field/varint_field' module Protobuf module Field class BoolField < VarintField def self.default false end def acceptable?(val) [true, false].include?(val) end def decode(value) value == 1 end def define_getter super field = self @message_class.class_eval do define_method("#{field.getter_method_name}?") do field.warn_if_deprecated @values.fetch(field.name, field.default_value) end end end def encode(value) [value ? 1 : 0].pack('C') end end end end
Version data entries
99 entries across 99 versions & 1 rubygems