Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Oj.mimic_JSON throws an error if json is already required. #13

Closed
fbernier opened this Issue · 2 comments

2 participants

@fbernier

Hi,

nothing like an example to describe this issue:

╰─○ irb
>> require 'json'
=> true
>> require 'oj'
=> true
>> Oj.mimic_JSON
TypeError: Generator is not a class
        from (irb):3:in `mimic_JSON'
        from (irb):3
        from /home/fbernier/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
>> Oj.mimic_JSON
=> JSON
╰─○ irb
>> require 'oj'
=> true
>> Oj.mimic_JSON
=> JSON

As you can see, if json is already included, it Oj,mimic_JSON thorws an error, but if I call it again, it works. Any clue on this?

@ohler55
Owner

mimic_JSON is meant to be used when replacing the json gem. It defines the JSON module. If you are already requiring json then you should not be using the mimic_JSON. I suppose I could make the call raise and error if the JSON module is already defined. It is doing the right thing but not providing a clear error message.

@ohler55
Owner

Code for a better error message has been checked in. It will be in the next release. Thanks for trying out mimic.

@ohler55 ohler55 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.