Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Resolve circular reference issue while generating JSON with Oj #250

Merged
merged 1 commit into from
Jun 19, 2016

Conversation

dgynn
Copy link
Contributor

@dgynn dgynn commented Jun 19, 2016

This PR addresses the problem identified in #70 where oj_mimic_json prevents the JSON response from being created.

Oj prefers as_json to to_json and previously the TimerStruct classes only implemented to_json. This commit adds as_json support that matches the to_json implementation so either way will work.

Specifically, the circular reference is between Page and Request (TimerStruct) objects where Page has reference to a @attributes[:root] Request and Request has a @page attribute.

I have not added test cases for this new code because as_json will only work if ActiveSupport extensions have loaded so that Hash has as_json support. The fix can be verified by adding the oj_mimic_json gem to an existing app.

@codecov-io
Copy link

Current coverage is 84.04%

Merging #250 into master will decrease coverage by 0.10%

@@             master       #250   diff @@
==========================================
  Files            21         21          
  Lines          1161       1166     +5   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            977        980     +3   
- Misses          184        186     +2   
  Partials          0          0          

Powered by Codecov. Last updated by 770665a...83f65b0

@SamSaffron
Copy link
Member

cool!

@SamSaffron SamSaffron merged commit 689aa19 into MiniProfiler:master Jun 19, 2016
@kbrock
Copy link
Contributor

kbrock commented Jun 20, 2016

Thanks so much. Many people wanted to get OJ working

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.

None yet

4 participants