| Inherits from | NSObject |
| Declared in | GBMethodsProvider.h<br />GBMethodsProvider.m |
A helper class that unifies methods handling.
Dividing implementation of methods provider to a separate class allows us to abstract the logic and reuse it within any object that needs to handle methods using composition. This breaks down the code into simpler and more managable chunks. It also simplifies methods parsing and handling. To use the class, simply "plug" it to the class that needs to handle methods and provide access through public interface.
The downside is that querrying code becomes a bit more verbose as another method or property needs to be sent before getting access to actual methods data.
- initWithParentObject:
Initializes methods provider with the given parent object.
- registerSectionWithName:
Registers a new section with the given name.
- registerSectionIfNameIsValid:
Registers a new section if the given name is valid section name.
sections
The array of all registered sections in the order of registration.
- registerMethod:
Registers the given method to the providers data.
- methodBySelector:
Returns the method that matches the given selector.
methods
The array of all registered methods as GBMethodData instances in the order of registration.
classMethods
The array of all registered class methods as GBMethodData instances sorten by method selector strings.
instanceMethods
The array of all registered instance methods as GBMethodData instances sorten by method selector strings.
properties
The array of all registered properties as GBMethodData instances sorten by property name strings.
- mergeDataFromMethodsProvider:
Merges data from the given methods provider.
hasSections
Specifies whether there is at least one section registered.
hasMultipleSections
Specifies whether there is are at least two sections registered.
hasClassMethods
Specifies whether there is are at least one class method registered.
hasInstanceMethods
Specifies whether there is are at least one instance method registered.
hasProperties
Specifies whether there is are at least one property registered.
Initializes methods provider with the given parent object.
- (id)initWithParentObject:(id)parentReturns initialized object.
Initializes methods provider with the given parent object.
The given parent object is set to each GBMethodData registered through registerMethod: . This is the designated initializer.
nil . GBMethodsProvider.hGBMethodsProvider.mMerges data from the given methods provider.
- (void)mergeDataFromMethodsProvider:(GBMethodsProvider *)source GBMethodsProvider to merge from. Merges data from the given methods provider.
This copies all unknown methods from the given source to receiver and invokes merging of data for receivers methods also found in source. It leaves source data intact.
GBMethodsProvider.hGBMethodsProvider.mReturns the method that matches the given selector.
- (GBMethodData *)methodBySelector:(NSString *)selector Returns method data or nil if no method matches the given selector.
Returns the method that matches the given selector.
If no method matches the given selector, nil is returned. If nil or empty string is passed for selector, nil is returned also.
GBMethodsProvider.hGBMethodsProvider.mRegisters the given method to the providers data.
- (void)registerMethod:(GBMethodData *)methodRegisters the given method to the providers data.
If provider doesn't yet have the given method instance registered, the object is added to methods list. If the same object is already registered, nothing happens. The method is also registered to the end of the list of methods for last registered section. If no section is registered a default section is created. However if another section is registered in such case, a warning is issued!
Note: If another instance of the method with the same selector is registered, an exception is thrown.
GBMethodsProvider.hGBMethodsProvider.mRegisters a new section if the given name is valid section name.
- (GBMethodSectionData *)registerSectionIfNameIsValid:(NSString *)name Returns created GBMethodSectionData object or nil if name is not valid.
Registers a new section if the given name is valid section name.
The method validates the name string to have at least one char in it. If so, it sends the receiver registerSectionWithName: message, passing it the given name and returns generated GBMethodSectionData object.. If the name is nil or empty string, no section is registered and nil is returned. This is provided only to simplify client code - i.e. no need for testing in each place where section should be registered, while on the other hand, validation tests are nicely encapsulated within the class itself, so no functionality is exposed.
GBMethodsProvider.hGBMethodsProvider.mRegisters a new section with the given name.
- (GBMethodSectionData *)registerSectionWithName:(NSString *)name Returns created GBMethodSectionData object.
Registers a new section with the given name.
This creates a new GBMethodSectionData object with empty array of methods and the given name. Any method registered from now on is added to this section until another section is registered. Registering a section with the same name as one of the existing sections logs a warning but adds the section anyway!
Important: If no section is registered when registering first method, default, no-name section (i.e. [GBMethodSectionData sectionName] value is nil ) is created automatically. However registering a second (and all subsequent) section would yield a warning in log! This aids creating simple objects which have no section. Note that only a log warning is issued, but all additional sections are added anyway.
GBMethodsProvider.hGBMethodsProvider.m The array of all registered class methods as GBMethodData instances sorten by method selector strings.
@property (readonly) NSArray *classMethods The array of all registered class methods as GBMethodData instances sorten by method selector strings.
This array is automatically filled when methods are registered by sending registerMethod: to the receiver. If there is no class method registered, empty array is returned.
GBMethodsProvider.hSpecifies whether there is are at least one class method registered.
@property (readonly) BOOL hasClassMethodsSpecifies whether there is are at least one class method registered.
This is mainly used as a helper for output generator. It is equivalent querrying for the number of class methods and check if the value is greater than 1, like this: [object.classMethods count] > 0 .
GBMethodsProvider.hSpecifies whether there is are at least one instance method registered.
@property (readonly) BOOL hasInstanceMethodsSpecifies whether there is are at least one instance method registered.
This is mainly used as a helper for output generator. It is equivalent querrying for the number of instance methods and check if the value is greater than 1, like this: [object.instanceMethods count] > 0 .
GBMethodsProvider.hSpecifies whether there is are at least two sections registered.
@property (readonly) BOOL hasMultipleSectionsSpecifies whether there is are at least two sections registered.
This is mainly used as a helper for output generator. It is equivalent querrying for the number of sections and check if the value is greater than 1, like this: [object.sections count] > 1 .
GBMethodsProvider.hSpecifies whether there is are at least one property registered.
@property (readonly) BOOL hasPropertiesSpecifies whether there is are at least one property registered.
This is mainly used as a helper for output generator. It is equivalent querrying for the number of propeties and check if the value is greater than 1, like this: [object.properties count] > 0 .
GBMethodsProvider.hSpecifies whether there is at least one section registered.
@property (readonly) BOOL hasSectionsSpecifies whether there is at least one section registered.
This is mainly used as a helper for output generator. It is equivalent querrying for the number of sections and check if the value is greater than 0, like this: [object.sections count] > 0 .
GBMethodsProvider.h The array of all registered instance methods as GBMethodData instances sorten by method selector strings.
@property (readonly) NSArray *instanceMethods The array of all registered instance methods as GBMethodData instances sorten by method selector strings.
This array is automatically filled when methods are registered by sending registerMethod: to the receiver. If there is no isntance method registered, empty array is returned.
GBMethodsProvider.h The array of all registered methods as GBMethodData instances in the order of registration.
@property (readonly) NSArray *methods The array of all registered methods as GBMethodData instances in the order of registration.
GBMethodsProvider.h The array of all registered properties as GBMethodData instances sorten by property name strings.
@property (readonly) NSArray *properties The array of all registered properties as GBMethodData instances sorten by property name strings.
This array is automatically filled when properties are registered by sending registerMethod: to the receiver. If there is no property registered, empty array is returned.
GBMethodsProvider.hThe array of all registered sections in the order of registration.
@property (readonly) NSArray *sectionsThe array of all registered sections in the order of registration.
Each section is represented as GBMethodSectionData object containing the name of the section and the list of all methods registered for that section.
GBMethodsProvider.h