Skip to content

Files

Latest commit

 

History

History
23 lines (15 loc) · 440 Bytes

Lint-ToJSON.md

File metadata and controls

23 lines (15 loc) · 440 Bytes

Pattern: Use of #to_json without optional argument

Issue: -

Description

When overriding #to_json, callers may invoke JSON generation via JSON.generate(your_obj). Since JSON#generate allows for an optional argument, your method should too.

Examples

# bad
def to_json
end

# good
def to_json(_opts)
end

Further Reading