Commit Graph

3 Commits

Author SHA1 Message Date
Jacob Fugal 1949a8b9e2 simplify OpenStruct/OpenObject json serialization
refs CNVS-7597

I could not find any instances of as_json being called directly (i.e.
not by to_json or the recursion in as_json). I could not find any
existing instances of nested OpenObjects (i.e. to trigger the recursion
in as_json). And it appears to me that we'd want the same object_type
"scoping" that to_json was doing even in a nested OpenObject#as_json. So
I move the object_type scoping from to_json to as_json; at this point,
to_json matched Object#to_json, and could be removed.

I introduce OpenStruct#as_json for consistency and to get rid of the
bare calls to OpenStruct#table in OpenObject#as_json.

With the recent change to Time#as_json, that branch in as_json can also
be simplified to value.as_json.

But the as_json calls on the subobjects are unnecessary; when the result
of the top-level as_json is json-encoded (through to_json), each element
will go through the appropriate ->as_json->to_json transformations as
well. So the .as_json calls can be dropped, and as_json (modulo the
object_type scoping) just becomes a call to table -- which is the
superclass' as_json. Handy!

test-plan: N/A

Change-Id: I783f1d3fbdcc6d71518c5f0f2d60a1faecc0c2fb
Reviewed-on: https://gerrit.instructure.com/23646
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2013-08-29 16:44:13 +00:00
Cody Cutrer 3cf998139d clean up OpenObject a bit
test plan:
 * existing specs should pass; no user visible changes
 * test particularly around dashboard stream items and grade summary pages

Change-Id: I81f82010df75bb104741fd325e85ca459dd9cfde
Reviewed-on: https://gerrit.instructure.com/13923
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-07-02 17:47:57 +00:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00