-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathLBModel.h
93 lines (80 loc) · 2.58 KB
/
LBModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @file LBModel.h
*
* @author Michael Schoonmaker
* @copyright (c) 2013 StrongLoop. All rights reserved.
*/
#import "SLRemoting.h"
/**
* A local representative of a single model instance on the server. The data is
* immediately accessible locally.
*/
@interface LBModel : SLObject
/**
* Returns the value associated with a given key.
*
* Used for NSDictionary-like subscripting:
* @code{.m}
* NSLog(somemodel[@"key"]);
* @endcode
*
* @param key The key for which to return the corresponding value.
* @return The value associated with `key`, or `nil` if no value is
* associated with `key`.
*/
- (id)objectForKeyedSubscript:(id <NSCopying>)key;
/**
* Adds a given key-value pair to the dictionary.
*
* Used for NSDictionary-like subscripting:
* @code{.m}
* somemodel[@"key"] = @"value";
* @endcode
*
* @param obj The value for aKey. A strong reference to the object is
* maintained by the dictionary. Raises an
* NSInvalidArgumentException if anObject is nil. If you need to
* represent a nil value in the dictionary, use NSNull.
* @param key The key for value. The key is copied (using copyWithZone:; keys
* must conform to the NSCopying protocol). Raises an
* NSInvalidArgumentException if aKey is nil. If aKey already exists
* in the dictionary anObject takes its place.
*/
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
/**
* Converts the LBModel (and all of its \@properties) into an NSDictionary.
*
* toDictionary should be overridden in child classes that wish to change this
* behaviour: hiding properties, adding computed properties, etc.
*/
- (NSDictionary *)toDictionary;
@end
/**
* A local representative of a single model type on the server, encapsulating
* the name of the model type for easy LBModel creation, discovery, and
* management.
*/
@interface LBModelRepository : SLRepository
/** The LBModel subclass used to wrap model instances. */
@property Class modelClass;
/**
* The SLRESTContract representing this model type's custom routes. Used to
* extend an Adapter to support this model type.
*
* @return A shared SLRESTContract for this model type.
*/
- (SLRESTContract *)contract;
/**
* Creates a new LBModel of this type without setting initial parameters.
*
* @return A new LBModel.
*/
- (LBModel *)model;
/**
* Creates a new LBModel of this type with the parameters described.
*
* @param dictionary The data to encapsulate.
* @return A new LBModel.
*/
- (LBModel *)modelWithDictionary:(NSDictionary *)dictionary;
@end