Skip to content

Commit

Permalink
add VERSION method to JSON::Backend packages to show VERSION of the a…
Browse files Browse the repository at this point in the history
…ctual backend module (JSON::XS, JSON::PP etc), for backward compatibility
  • Loading branch information
charsbar committed May 18, 2017
1 parent ec9ac56 commit 9025223
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/JSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ sub init {

sub is_xs { 0 };
sub is_pp { 1 };
sub VERSION { $JSON::BackendModule->VERSION }

#
# To save memory, the below lines are read only when XS backend is used.
Expand Down Expand Up @@ -407,6 +408,7 @@ sub init {
sub is_xs { 1 };
sub is_pp { 0 };
sub VERSION { $JSON::BackendModule->VERSION }
sub support_by_pp {
my ($class, @methods) = @_;
Expand Down

2 comments on commit 9025223

@Grinnz
Copy link

@Grinnz Grinnz commented on 9025223 May 18, 2017

Choose a reason for hiding this comment

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

This isn't quite correct: VERSION must also pass through any arguments it receives, as it's often used as Some::Class->VERSION('X.Y'), this is the correct way to compare versions.

@charsbar
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing out. Fixed this with c15af5d

Please sign in to comment.