Inherits from NSObject
Declared in RKDynamicMappingMatcher.h

Overview

The RKDynamicMappingMatcher class provides an interface for encapsulating the selection of an object mapping based on the runtime value of a property at a given key path. A 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.

Tasks

Initializing a Matcher

Evaluating a Match

  • – matches:

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

Properties

expectedValue

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

@property (nonatomic, strong, readonly) id expectedValue

Declared In

RKDynamicMappingMatcher.h

keyPath

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

@property (nonatomic, copy, readonly) NSString *keyPath

Declared In

RKDynamicMappingMatcher.h

objectMapping

The object mapping object that applies if the comparison value read from keyPath is equal to the expectedValue.

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

Declared In

RKDynamicMappingMatcher.h

Instance Methods

initWithKeyPath:expectedValue:objectMapping:

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

- (id)initWithKeyPath:(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

RKDynamicMappingMatcher.h

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.

Discussion

The match is evaluated by invoking valueForKeyPath: on the give object with the value of the keyPath property and comparing the returned value with the expectedValue using the RKObjectIsEqualToObject function.

Declared In

RKDynamicMappingMatcher.h