···152 instance_variables - [:@type_object, :@data_object, :@blocks]
153 end
154155- # Checks if all required fields are set in the data object.
156- # @param fields [Array<String>] list of fields to check
157- # @raise [DecodeError] if any of the fields is nil or not set
158- def check_if_not_nil(fields)
159- missing = fields.select { |f| @data_object[f].nil? }
160161- raise DecodeError.new("Missing event details (#{missing.map(&:to_s).join(', ')})") if missing.length > 0
162- end
16300000000164165- private
00000166167 def self.decode_cbor_objects(data)
168 objects = CBOR.decode_sequence(data)
···152 instance_variables - [:@type_object, :@data_object, :@blocks]
153 end
15400000155156+ private
0157158+ # Note: this method is written this way as an optimization
159+ def check_if_not_nil(a, b = nil, c = nil, d = nil, e = nil, f = nil)
160+ ok = @data_object.has_key?(a)
161+ ok &&= @data_object.has_key?(b) if b
162+ ok &&= @data_object.has_key?(c) if c
163+ ok &&= @data_object.has_key?(d) if d
164+ ok &&= @data_object.has_key?(e) if e
165+ ok &&= @data_object.has_key?(f) if f
166167+ if !ok
168+ expected_fields = [a, b, c, d, e, f].compact
169+ missing_fields = expected_fields.select { |x| @data_object[x].nil? }
170+ raise DecodeError.new("Missing event details (#{missing_fields.map(&:to_s).join(', ')})")
171+ end
172+ end
173174 def self.decode_cbor_objects(data)
175 objects = CBOR.decode_sequence(data)