Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
JSON::Ext::Generator::State#initialize_copy
(self object) -> self
initialize_copy(orig)
ext/json/generator/generator.c
View on GitHub ↗
static VALUE cState_init_copy(VALUE obj, VALUE orig)
{
JSON_Generator_State *objState, *origState;
if (obj == orig) return obj;
GET_STATE_TO(obj, objState);
GET_STATE_TO(orig, origState);
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
MEMCPY(objState, origState, JSON_Generator_State, 1);
RB_OBJ_WRITTEN(obj, Qundef, objState->indent);
RB_OBJ_WRITTEN(obj, Qundef, objState->space);
RB_OBJ_WRITTEN(obj, Qundef, objState->space_before);
RB_OBJ_WRITTEN(obj, Qundef, objState->object_nl);
RB_OBJ_WRITTEN(obj, Qundef, objState->array_nl);
RB_OBJ_WRITTEN(obj, Qundef, objState->as_json);
RB_OBJ_WRITTEN(obj, Qundef, objState->sort_keys);
return obj;
}
Initializes this object from orig if it can be duplicated/cloned and returns it.