Skip to content

Commit

Permalink
Warn on implicit Oj::Rails.mimic_JSON (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov authored Jun 19, 2022
1 parent a8900b0 commit c1fb777
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ext/oj/mimic_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ static VALUE mimic_generate_core(int argc, VALUE *argv, Options copts) {
VALUE active_hack[1];

if (Qundef == state_class) {
rb_warn(
"Oj::Rails.mimic_JSON was called implicitly. "
"Call it explicitly beforehand if you want to remove this warning."
);
oj_define_mimic_json(0, NULL, Qnil);
}
active_hack[0] = rb_funcall(state_class, oj_new_id, 0);
Expand Down Expand Up @@ -481,6 +485,10 @@ oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self) {
rb_hash_aset(h, oj_array_nl_sym, rb_str_new2("\n"));
}
if (Qundef == state_class) {
rb_warn(
"Oj::Rails.mimic_JSON was called implicitly. "
"Call it explicitly beforehand if you want to remove this warning."
);
oj_define_mimic_json(0, NULL, Qnil);
}
rargs[1] = rb_funcall(state_class, oj_new_id, 1, h);
Expand Down

0 comments on commit c1fb777

Please sign in to comment.