Skip to content

Commit feab022

Browse files
author
Josh Callender
committed
added documentation for the model-utils class
1 parent 77d3924 commit feab022

File tree

9 files changed

+60
-14
lines changed

9 files changed

+60
-14
lines changed

Gemfile.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ GEM
1616
coffee-script (2.3.0)
1717
coffee-script-source
1818
execjs
19-
coffee-script-source (1.8.0)
19+
coffee-script-source (1.9.0)
2020
colorator (0.1)
21-
execjs (2.2.2)
21+
execjs (2.3.0)
2222
fast-stemmer (1.0.2)
2323
ffi (1.9.6)
2424
gemoji (2.1.0)
25-
github-pages (32)
25+
github-pages (33)
2626
RedCloth (= 4.2.9)
2727
github-pages-health-check (~> 0.2)
2828
jekyll (= 2.4.0)
@@ -36,7 +36,7 @@ GEM
3636
liquid (= 2.6.1)
3737
maruku (= 0.7.0)
3838
mercenary (~> 0.3)
39-
pygments.rb (= 0.6.0)
39+
pygments.rb (= 0.6.1)
4040
rdiscount (= 2.1.7)
4141
redcarpet (= 3.1.2)
4242
terminal-table (~> 1.4)
@@ -75,7 +75,7 @@ GEM
7575
jekyll-sass-converter (1.2.0)
7676
sass (~> 3.2)
7777
jekyll-sitemap (0.6.3)
78-
jekyll-watch (1.2.0)
78+
jekyll-watch (1.2.1)
7979
listen (~> 2.7)
8080
jemoji (0.4.0)
8181
gemoji (~> 2.0)
@@ -93,22 +93,22 @@ GEM
9393
mini_portile (0.6.2)
9494
minitest (5.5.1)
9595
net-dns (0.8.0)
96-
nokogiri (1.6.6.1)
96+
nokogiri (1.6.6.2)
9797
mini_portile (~> 0.6.0)
9898
parslet (1.5.0)
9999
blankslate (~> 2.0)
100-
posix-spawn (0.3.9)
100+
posix-spawn (0.3.10)
101101
public_suffix (1.4.6)
102-
pygments.rb (0.6.0)
102+
pygments.rb (0.6.1)
103103
posix-spawn (~> 0.3.6)
104-
yajl-ruby (~> 1.1.0)
104+
yajl-ruby (~> 1.2.0)
105105
rb-fsevent (0.9.4)
106106
rb-inotify (0.9.5)
107107
ffi (>= 0.5.0)
108108
rdiscount (2.1.7)
109109
redcarpet (3.1.2)
110110
safe_yaml (1.0.4)
111-
sass (3.4.10)
111+
sass (3.4.12)
112112
terminal-table (1.4.5)
113113
thread_safe (0.3.4)
114114
timers (4.0.1)
@@ -117,10 +117,10 @@ GEM
117117
parslet (~> 1.5.0)
118118
tzinfo (1.2.2)
119119
thread_safe (~> 0.1)
120-
yajl-ruby (1.1.0)
120+
yajl-ruby (1.2.1)
121121

122122
PLATFORMS
123123
ruby
124124

125125
DEPENDENCIES
126-
github-pages (= 32)
126+
github-pages (= 33)

_app/constructor.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ header: constructor
33
example: new App([attributes], [options])
44
---
55

6-
Creates an instance of the application, setting the modelUtils, [fetcher](/fetcher), and [router](/router) to the app object. The attributes are attributes you wish to set on the application. See the [configuration](#config) object for more details about options that can be passed into the constructor.
6+
Creates an instance of the application, setting the [modelUtils](/model-utils), [fetcher](/fetcher), and [router](/router) to the app object. The attributes are attributes you wish to set on the application. See the [configuration](#config) object for more details about options that can be passed into the constructor.

_model-utils/getCollection.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
header: getCollection
3+
example: ModelUtils.getCollection(path, [models], [options], [callback])
4+
---
5+
6+
Factory method for collections. Given the path of a collection, will return an instance of that collection. This will also add the `models` to that collection, and set any `options` to the collection. `callback` allows the method to be called asynchronously.
7+
8+
**path** The path to the collection, for example: `my_collection`, would return an instance of a collection stored in `app/collections/my_collection.js`
9+
10+
**models** _optional_ An array of models to store in the collection.
11+
12+
**options** _optional_ Options for the [collection constructor](/collection#constructor).
13+
14+
**callback** _optional_ Callback function to be invoked once the instance is created. If it's not defined, this will return the instance instead.

_model-utils/getModel.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
header: getModel
3+
example: ModelUtils.getModel(path, [attributes], [options], [callback])
4+
---
5+
6+
Factory method for models, given the models path this will return an instance of that model. Sets the given `attributes` and `options` on the model.
7+
8+
**attributes** _optional_ The attributes for the [constructor](/model#constructor).
9+
10+
**options** _optional_ The options to set in a constructor method.
11+
12+
**callback** _optional_ Allows the constructor to be called with a callback method instead.

_model-utils/isCollection.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
header: isCollection
3+
example: ModelUtils.isCollection(obj)
4+
---
5+
6+
Returns a boolean if the `obj` is an instance of a [Collection](/collection).

_model-utils/isModel.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
header: isModel
3+
example: ModelUtils.isModel(obj)
4+
---
5+
6+
Returns a boolean if the `obj` is an instance of a [Model](/model).

_model-utils/underscorize.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
header: underscorize
3+
example: ModelUtils.underscorize(name)
4+
---
5+
6+
Return a snake case version of the model or collection name. For example: `MyModel` would return `my_model`.

app/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The App is a specialized [Model](/model). A lot of the choices between client /
1010
- Defines the template adapter
1111
- Initializes the client / server [router](/router)
1212
- Initializes the [fetcher](/fetcher)
13-
- Initializes modelUtils
13+
- Initializes [modelUtils](/model-utils)
1414
- Initializes the app view, which in turn will initialize all views in use
1515
- [Starts](#start) the client-side [router](/router)
1616
- [Bootstraps the data](#bootstrapData) from the server into the client

model-utils/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ title: "Model Utils - RendrJS"
55

66
# Model Utils
77

8+
This class gives utility functions for models and collections. Some functionality includes; an `instanceof` wrappers, factory methods, and getters for constructors based on the name. The ModelUtils class is initialized in the [app initialization](/app#constructor) process, and is attached to the [app](/app) object.
9+
810
{% include pageDoc.html name="model-utils" %}

0 commit comments

Comments
 (0)