Inherits from NSObject
Declared in SIStepMapping.h

Overview

Used to store a cross reference between a step mapping method and the class that contains it. The mapping is tested by using a regular expression. If the text of a step is matched by this regular expression, then the SIStepMapping instance is mapped to the step. Any given SIStep can only map to a single SIStepMapping. but a SIStepMapping instance can execute with data from any number of steps from any number of stories. This provides a way to centralise the code across multiple stories.

Tasks

Properties

  •   regex

    The regular expression object used to test each mapping.

    property
  •   selector

    I the SIStepMapping matches via the regex, this is the selector that will be executed.

    property
  •   targetClass

    This is the target class that contains the selector to be executed. This class will be instantiated just once for each story that is executed.

    property
  •   mapped

    Indicates whether the mapping was mapped.

    property

Initialisers

Tasks

  • – canMapToStep:

    Checks whether this instance can be applied to the passed SIStep. This executes the regular expression against the step and return whether it matched. If a match is made then the mapped property is set to indicate that the step mapping was mapped.

  • – invokeWithCommand:object:error:

    Called by the SIStep to invoke the implementaton that is mapped to the step.

  • – reset

    Returns YES if the step has been mapping during the findMappingInList: method.

Properties

mapped

Indicates whether the mapping was mapped.

@property (nonatomic, assign) BOOL mapped

Discussion

Indicates whether the mapping was mapped.

Declared In

SIStepMapping.h

regex

The regular expression object used to test each mapping.

@property (nonatomic, retain) NSRegularExpression *regex

Discussion

The regular expression object used to test each mapping.

Declared In

SIStepMapping.h

selector

I the SIStepMapping matches via the regex, this is the selector that will be executed.

@property (nonatomic, assign) SEL selector

Discussion

I the SIStepMapping matches via the regex, this is the selector that will be executed.

Declared In

SIStepMapping.h

targetClass

This is the target class that contains the selector to be executed. This class will be instantiated just once for each story that is executed.

@property (nonatomic, assign) Class targetClass

Discussion

This is the target class that contains the selector to be executed. This class will be instantiated just once for each story that is executed.

Declared In

SIStepMapping.h

Class Methods

stepMappingWithClass:selector:regex:error:

Factory method for creating an instance of the mapping.

+ (SIStepMapping *)stepMappingWithClass:(Class)theClass selector:(SEL)aSelector regex:(NSString *)theRegex error:(NSError **)error

Parameters

theClass

the class that the mapping applies to.

aSelector

the selector to be executed.

theRegex

the regular expression used to match the text from a step.

error

a pointer to a reference to an NSError. This is populated if there is an error.

Return Value

the newly created, autoreleased instance.

Discussion

Factory method for creating an instance of the mapping.

Declared In

SIStepMapping.h

Instance Methods

canMapToStep:

Checks whether this instance can be applied to the passed SIStep. This executes the regular expression against the step and return whether it matched. If a match is made then the mapped property is set to indicate that the step mapping was mapped.

- (BOOL)canMapToStep:(NSString *)step

Parameters

step

the step to check.

Return Value

YES if the regular expression matches. NO otherwise.

Discussion

Checks whether this instance can be applied to the passed SIStep. This executes the regular expression against the step and return whether it matched. If a match is made then the mapped property is set to indicate that the step mapping was mapped.

Declared In

SIStepMapping.h

invokeWithCommand:object:error:

Called by the SIStep to invoke the implementaton that is mapped to the step.

- (BOOL)invokeWithCommand:(NSString *)command object:(id)object error:(NSError **)error

Parameters

command

the text line from the story.

object

the instantiated targetClass which contains the implementation code.

error

a pointer to a reference to an NSError. This is populated if there is an error.

Return Value

YES if the invokation was successful. NO otherwise.

Discussion

Called by the SIStep to invoke the implementaton that is mapped to the step.

Declared In

SIStepMapping.h

reset

Returns YES if the step has been mapping during the findMappingInList: method.

- (void)reset

Discussion

Returns YES if the step has been mapping during the findMappingInList: method.

Declared In

SIStepMapping.h