Skip to content

Keep the declared MultiJson minimum working after the API rename - #289

Closed
OskarEichler wants to merge 1 commit into
trailblazer:masterfrom
OskarEichler:codex/legacy-multi-json
Closed

Keep the declared MultiJson minimum working after the API rename#289
OskarEichler wants to merge 1 commit into
trailblazer:masterfrom
OskarEichler:codex/legacy-multi-json

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Merged #273 uses MultiJSON.parse/generate, but the optional dependency minimum (multi_json 1.14.1) exposes only MultiJson.load/dump. Select legacy names when the modern module is absent.

Reproduction

# With multi_json 1.14.1 activated:
require 'representable/json'
mod=Module.new { include Representable::JSON; property :name }
p Struct.new(:name).new('value').extend(mod).to_json
# Current master raises NameError for MultiJSON; this patch renders JSON.

Verification

  • Existing master suite on this isolated branch: 545 tests / 701 assertions, zero failures/errors, three existing skips on Ruby 3.2.11. Ruby 4.0.6 retains the same eight legacy inspection-format failures, zero errors and three skips. Existing tests/expectations are unchanged.
  • 140 focused checks on Ruby 3.2.11/4.0.6 for this change. XML first-render uses a separate fresh-process check.
  • Combined release-based verification with other focused fixes and attributed Use Setter in OverwriteOnNil if a :setter is defined #177/Hash value of null breaks parsing #264/Update MultiJSON usage to address deprecations #273 source backports: 544 tests / 700 assertions pass on Ruby 3.2.11, plus 4,410 focused checks and 36 boundary checks. Package retains 104 paths and unchanged compared metadata. All 36 runtime files compile on both Rubies; no newly introduced default Lint offenses.

With multi_json 1.14.1 as well as installed 1.21.1, 140 focused JSON roundtrips pass on Ruby 4.0.6 with deprecation warnings enabled. Current master against 1.14.1 reproduces NameError for MultiJSON. The isolated old-version suite retains the same 545/701 result and eight Ruby 4 inspection failures.

Breaking changes / limitations

No dependency bump or range narrowing. Modern MultiJSON stays on its warning-free API and the declared legacy range works again.

No new/modified checked-in tests. Ruby 2.4–3.1, JRuby, Windows and Linux were not executed locally. Ruby >=2.4 and runtime dependency ranges remain unchanged. External test tooling supplies a legacy MiniTest alias and ruby-prof 1.7.x; no assertions were changed. No production verification is claimed.

Comment thread lib/representable/json.rb
def from_json(data, *args)
data = MultiJSON.parse(data)
data = defined?(::MultiJSON) ? ::MultiJSON.parse(data) : ::MultiJson.load(data)
from_hash(data, *args)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something that should be checked once at compile time, when the gem is loaded, and not at every parsing and rendering invocation. Maybe Claude isn't aware that this is very bad style, but we are.

@seuros

seuros commented Aug 28, 2026

Copy link
Copy Markdown
Member

This a non-sense AI SLOP without any human supervision or even testing.

The code is guarded in line 1, that code will never run if the gem is not present.

@seuros seuros closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants