Class: Object

Inherits:
BasicObject
Defined in:
lib/ffi_yajl/ffi/encoder.rb

Overview

I feel dirty

Instance Method Summary collapse

Instance Method Details

#ffi_yajl(rb_yajl_gen, state) ⇒ Object



342
343
344
345
346
347
348
349
350
351
352
# File 'ext/ffi_yajl/ext/encoder/encoder.c', line 342

def ffi_yajl(yajl_gen, state)
  if !state[:processing_key] && respond_to?(:to_json)
    str = to_json(state[:json_opts])
    # #yajl_gen_number outputs a string without quotes around it
    status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize)
  else
    str = to_s
    status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)
  end
  FFI_Yajl::Encoder.raise_error_for_status(status, str) if ( status ) != 0
end