[WIP] Moved JSON dictionary and array transformers to MTLJSONAdapter #258

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Member

dcaunt commented Mar 6, 2014

Implements changes suggested in #203

Closes #203

@robb robb commented on an outdated diff Mar 6, 2014

Mantle/MTLJSONAdapter.h
@@ -170,6 +171,28 @@
@interface MTLJSONAdapter (ValueTransformers)
+// Creates a reversible transformer to convert a JSON dictionary into a MTLModel
+// object, and vice-versa.
+//
+// modelClass - The MTLModel subclass to attempt to parse from the JSON. This
+// class must conform to <MTLJSONSerializing>. This argument must
+// not be nil.
+//
+// Returns a reversible transformer which uses MTLJSONAdapter for transforming
@robb

robb Mar 6, 2014

Owner

This should point out that we always use the class of the receiver.

@robb robb and 1 other commented on an outdated diff Mar 6, 2014

Mantle/MTLJSONAdapter.h
+// modelClass - The MTLModel subclass to attempt to parse from the JSON. This
+// class must conform to <MTLJSONSerializing>. This argument must
+// not be nil.
+//
+// Returns a reversible transformer which uses MTLJSONAdapter for transforming
+// values back and forth.
++ (NSValueTransformer<MTLTransformerErrorHandling> *)dictionaryTransformerWithModelClass:(Class)modelClass;
+
+// Creates a reversible transformer to convert an array of JSON dictionaries
+// into an array of MTLModel objects, and vice-versa.
+//
+// modelClass - The MTLModel subclass to attempt to parse from each JSON
+// dictionary. This class must conform to <MTLJSONSerializing>.
+// This argument must not be nil.
+//
+// Returns a reversible transformer which uses MTLJSONAdapter for transforming
@robb

robb Mar 6, 2014

Owner

Same as above.

@dcaunt

dcaunt Mar 6, 2014

Member

👍 I was going to suggest the same thing

Owner

robb commented Mar 6, 2014

👍 nice!

Can you add a test that verifies that if this is invoked on a subclass of MTLJSONAdapter, the subclass is used for serialization?

robb added this to the 2.0 milestone Mar 6, 2014

robb self-assigned this Mar 6, 2014

Member

dcaunt commented Mar 6, 2014

Sure, though I'm not sure how best to test it. Is there a better way than checking serialization matches that expected for a given subclass?

Owner

robb commented Mar 6, 2014

Hmm, not sure there is a nice way without adding mocks. I guess using a subclass with an implicit transformer is the easiest way.

Owner

jspahrsummers commented Mar 13, 2014

Sorry, just catching up—is this still a WIP?

Member

dcaunt commented Mar 13, 2014

I'm afraid so. Just need to sort out a test but the implementation is done.

On Thursday, 13 March 2014, Justin Spahr-Summers notifications@github.com
wrote:

Sorry, just catching up—is this still a WIP?


Reply to this email directly or view it on GitHubhttps://github.com/MantleFramework/Mantle/pull/258#issuecomment-37582161
.

Owner

robb commented Mar 13, 2014

I believe it's still missing a test to verify the use of subclasses

On Mar 13, 2014, at 21:24, Justin Spahr-Summers notifications@github.com wrote:

Sorry, just catching up—is this still a WIP?


Reply to this email directly or view it on GitHub.

Owner

jspahrsummers commented Mar 13, 2014

🆒 No worries, just checking.

Member

dcaunt commented Apr 11, 2014

Do you think we should add OCMock to verify this? I can't come up with a test that doesn't feel really hacky.

Owner

robb commented Apr 11, 2014

I'd rather not. What's wrong with adding a subclass like MTLTestJSONAdapter?

robb was unassigned by dcaunt Apr 16, 2014

Owner

robb commented Aug 31, 2014

@dcaunt are still interested in working on this?

jspahrsummers referenced this pull request Mar 16, 2015

Merged

Move JSON transformers to MTLJSONAdapter (redux) #474

1 of 1 task complete
Owner

jspahrsummers commented Mar 16, 2015

Superseded by #474.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment