Expose -JSONKeyPathForKey: #199

Merged
merged 3 commits into from Dec 12, 2013

4 participants

@robb
Mantle member

By exposing this method, subclasses can decide which property to serialize.

In 2.0-development, this method needs to be restored since the cached dictionary is currently accessed directly.

Fixes #185

/cc @dcaunt

@robb robb and 1 other commented on an outdated diff Dec 11, 2013
Mantle/MTLJSONAdapter.h
@@ -121,6 +121,14 @@
// Returns a JSON dictionary, or nil if a serialization error occurred.
- (NSDictionary *)JSONDictionary;
+// Looks up the JSON key path that corresponds to the given key.
+//
+// key - The property key to retrieve the corresponding JSON key path for. This
+// argument must not be nil.
+//
+// Returns a key path to use, or nil to omit the property from JSON.
+- (NSString *)JSONKeyPathForKey:(NSString *)key;
@robb
Mantle member
robb added a note Dec 11, 2013

any reason why this isn't -JSONKeyPathForPropertyKey:?

@jspahrsummers
Mantle member

It wasn't public before, so the naming was less important. I'd rather use your suggestion now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jspahrsummers jspahrsummers and 1 other commented on an outdated diff Dec 11, 2013
Mantle/MTLJSONAdapter.h
@@ -121,6 +121,14 @@
// Returns a JSON dictionary, or nil if a serialization error occurred.
- (NSDictionary *)JSONDictionary;
+// Looks up the JSON key path that corresponds to the given key.
+//
@jspahrsummers
Mantle member

Can you add some additional text explaining how this method is intended to be used? I don't want users thinking they should call it directly for some reason.

@jspahrsummers
Mantle member

Alternatively, maybe we could put this into a +Subclass header (a la UIGestureRecognizer).

@robb
Mantle member
robb added a note Dec 11, 2013

I think I'd prefer some documentation over having to import another header.

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

👞

@robb
Mantle member

@dcaunt
Mantle member

Looks good @robb ! 🍌

@jspahrsummers
Mantle member

🏈

@jspahrsummers jspahrsummers merged commit 439be82 into master Dec 12, 2013

1 check passed

Details default Build #842017 succeeded in 40s
@jspahrsummers jspahrsummers deleted the keypath-hook branch Dec 12, 2013
@paulyoung

Could there be a release made which includes this change?

@robb
Mantle member

We're looking into it

@dcaunt
Mantle member

@paulyoung 1.4 is live on CocoaPods now too ☀️

@paulyoung

👍

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