Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
JSON::Ext::Generator::State.from_state
from_state(opts)
ext/json/generator/generator.c
View on GitHub ↗
static VALUE cState_from_state_s(VALUE self, VALUE opts)
{
if (rb_obj_is_kind_of(opts, self)) {
return opts;
} else if (rb_obj_is_kind_of(opts, rb_cHash)) {
return rb_funcall(self, i_new, 1, opts);
} else {
return rb_class_new_instance(0, NULL, cState);
}
}
Creates a State object from opts, which ought to be Hash to create a new State instance configured by opts, something else to create an unconfigured instance. If opts is a State object, it is just returned.
See also
.default_sort_keys_proc=
.generate
._generate_no_fallback
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0