- Inherits from:
- NSObject
- Conforms to:
- NSCoding
- BDPropertyListEncoding (informal protocol)
- Declared in:
- BDRuleEngine/BDRuleModel.h
A BDRuleModel respresents a collection of rules within the rule system.
A BDRuleModel is a collection of rules within the rule system. Rule models can be initialized with the contents of ruleSet files or arrays of rules, or they can have their rules added manually.
Rule models can also return a collection of candidate rules to use when looking up the value of a given key. These candidate rules are all the rules that have the requested key as their right-hand side's key path. The returned candidate rules are sorted first according to their priority, and then according to the number of qualifier keys in their left-hand side.
- NSCoding
- -encodeWithCoder:
- -initWithCoder:
- BDPropertyListEncoding (informal protocol)
- -encodeIntoPropertyList:
- -initWithPropertyList:owner:
- -awakeWithPropertyList:
- Initialization
- -init
- -initWithRules:
- -initWithContentsOfFile:
- -initWithRulesFromOldStylePlistRep:
- -initWithRulesFromOldStyleFile:
- Writing to a File
- -writeToFile:atomically:
- Accessors
- -setRules:
- -rules
- -addToRules:
- -removeFromRules:
- Finding Candidate Rules
- -candidateRulesForKey:
- (void)addToRules:(BDRule *)value
Adds the rule value to the rule model's rule set.
- (NSArray *)candidateRulesForKey:(NSString *)key
Locates all of the candidate rules that might apply for the given key.
Candidate rules are rules whose right-hand side key path matches key. The returned candidate rules are sorted in descending order first according to priority, and then according to the number of qualifier keys in their left-hand side. Thus candidate rules are returned in most-specific to least-specific order.
- (id)init
Initializes an instance of BDRuleModel with an empty rule set.
- (id)initWithRules:(NSArray *)rules
Initializes an instance of BDRuleModel with the rules in the array.
Note: This is the designated initializer.
- (id)initWithContentsOfFile:(NSArray *)path
Initializes an instance of BDRuleModel with the property list representation of a set of rules located in the file at path.
- (id)initWithRulesFromOldStylePlistRep:(NSArray *)plistRep
Initializes an instance of BDRuleModel with the old-style property list representation of a set of rules.
- (id)initWithRulesFromOldStyleFile:(NSArray *)path
Initializes an instance of BDRuleModel with the property list representation of a set of rules located in the old-style rules file at path.
- (void)removeFromRules:(NSString *)value
Removes the rule value from the rule model's rule set.
- (NSArray *)rules
Returns all of the rules in this rule model's rule set.
- (void)setRules:(NSArray *)value
Sets the rule model's rule set to contain all of the rules in the array value. Rules may still be added and removed.
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
Writes the property-list representation of the rule set to the file at path. If flag is set, it will write to a temporary file on the same volume and then move the temporary file to path if the write is successful.
Returns whether the file was written.