Inherits from NSObject
Declared in RKObjectMappingMatcher.h

Overview

The RKObjectMappingMatcher class provides an interface for encapsulating the selection of an object mapping based on runtime values. Matcher objects may be configured by key path and expected value or with a predicate object.

Key Path Matching

A key path matcher object is initialized with a key path, an expected value to be read from the key path, and an object mapping that is to be applied if the match evaluates to YES. When evaluating the match, the matcher invokes valueForKeyPath: on the object being matched and compares the value returned with the expectedValue via the RKObjectIsEqualToObject function. This provides a flexible, semantic match of the property value.

Predicate Matching

A predicate matcher object is initialized with a predicate object and an object mapping that is to be applied if the predicate evaluates to YES for the object being matched.

Tasks

Constructing Key Path Matchers

Constructing Predicate Matchers

Accessing the Object Mapping

  •   objectMapping

    The object mapping object that applies when the receiver matches a given object.

    property

Evaluating a Match

  • – matches:

    Returns a Boolean value that indicates if the given object matches the expectations of the receiver.

Properties

objectMapping

The object mapping object that applies when the receiver matches a given object.

@property (nonatomic, strong, readonly) RKObjectMapping *objectMapping

Declared In

RKObjectMappingMatcher.h

Class Methods

matcherWithKeyPath:expectedValue:objectMapping:

Creates and returns a key path matcher object with a given key path, expected value, and an object mapping that applies in the event of a positive match.

+ (instancetype)matcherWithKeyPath:(NSString *)keyPath expectedValue:(id)expectedValue objectMapping:(RKObjectMapping *)objectMapping

Parameters

keyPath

The key path to obtain the comparison value from the object being matched via valueForKeyPath:.

expectedValue

The value that is expected to be read from keyPath if there is a match.

objectMapping

The object mapping object that applies if the comparison value is equal to the expected value.

Return Value

The receiver, initialized with the given key path, expected value, and object mapping.

Declared In

RKObjectMappingMatcher.h

matcherWithPredicate:objectMapping:

Creates and returns a predicate matcher object with a given predicate and an object mapping that applies in the predicate evaluates positively.

+ (instancetype)matcherWithPredicate:(NSPredicate *)predicate objectMapping:(RKObjectMapping *)objectMapping

Parameters

predicate

The predicate with which to evaluate the matched object.

objectMapping

The object mapping object that applies if the predicate evaluates positively for the matched object.

Return Value

The receiver, initialized with the given key path, expected value, and object mapping.

Declared In

RKObjectMappingMatcher.h

Instance Methods

matches:

Returns a Boolean value that indicates if the given object matches the expectations of the receiver.

- (BOOL)matches:(id)object

Parameters

object

The object to be evaluated.

Return Value

YES if the object matches the expectations of the receiver, else NO.

Declared In

RKObjectMappingMatcher.h