Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add JSON additional signatures #597

Merged
merged 1 commit into from
Feb 15, 2021
Merged

Add JSON additional signatures #597

merged 1 commit into from
Feb 15, 2021

Conversation

ybiquitous
Copy link
Contributor

This change adds extended signatures (e.g. #as_json or .json_create) for JSON additional classes:

  • BigDecimal
  • Complex
  • DateTime
  • Date
  • Exception
  • OpenStruct
  • Range
  • Rational
  • Regexp
  • Set
  • Struct
  • Symbol
  • Time

See https://github.com/flori/json/blob/v2.5.1/lib/json/add/

Related to #592

This change adds extended signatures (e.g. `#as_json` or `.json_create`) for JSON additional classes:

- BigDecimal
- Complex
- DateTime
- Date
- Exception
- OpenStruct
- Range
- Rational
- Regexp
- Set
- Struct
- Symbol
- Time

See <https://github.com/flori/json/blob/v2.5.1/lib/json/add/>
# Deserializes JSON string by constructing new Range object with arguments `a`
# serialized by `to_json`.
#
def self.json_create: (Hash[String, String | [Elem, Elem, bool]] object) -> instance
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Goodcheck] Prefer boolish over bool for method arguments and block return values (view)

See the doc below:
https://github.com/ruby/rbs/blob/78d04a2db0f1c4925d2b13c2939868edf9465d6c/docs/syntax.md#bool-or-boolish

Rule
rbs.prefer_boolish

You can close this issue if no need to fix it. Learn more.

Range#exclude_end? returns bool so I think bool should be correct here. See below:
https://github.com/flori/json/blob/v2.5.1/lib/json/add/range.rb#L19

def `exclude_end?`: () -> bool

@ybiquitous ybiquitous marked this pull request as ready for review February 13, 2021 02:42
#
# method used for JSON marshalling support.
#
def as_json: (*untyped) -> Hash[String, String]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[question] Is there a better way than *untyped?

Copy link
Member

Choose a reason for hiding this comment

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

It's not very clear... *untyped would be a good solution. 🙄

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

Thank you @ybiquitous! Great effort! 💪

@soutaro soutaro merged commit 97b897e into ruby:master Feb 15, 2021
@ybiquitous ybiquitous deleted the json-add branch February 15, 2021 23:51
@ybiquitous
Copy link
Contributor Author

@soutaro Thank you so much for the review and merge! 😄

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants