Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One can now access internal scope classes for extending functionality to Collection+JSON
- Loading branch information
Showing
6 changed files
with
45 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,10 +1,49 @@ | |||
cscj = require("coffee-dsl").dsl() | module.exports = require("coffee-dsl").dsl() | ||
Collection = require "./collection" | |||
|
|
||
cscj.set "collection", (collectionFun)-> | module.exports.set "collection", (collectionFun)-> | ||
collection = {version:"1.0"} | collection = {version:"1.0"} | ||
root = {collection:collection} | root = {collection:collection} | ||
collectionFun.call new Collection(collection) | collectionFun.call new exports.Collection(collection) | ||
root | root | ||
|
|
||
module.exports = cscj | exports.Base = class Base | ||
constructor: (@_obj) -> | |||
href: (value)-> | |||
@_obj.href = value | |||
|
|||
exports.Data = class Data extends exports.Base | |||
datum: (options)-> | |||
@_obj.data ||= [] | |||
@_obj.data.push options | |||
|
|||
# expose internal objects for extensions | |||
exports.Collection = class Collection extends Base | |||
error: (options)-> | |||
@_obj.error = options | |||
link: (options)-> | |||
@_obj.links ||= [] | |||
@_obj.links.push options | |||
item: (itemFun)-> | |||
item = {} | |||
@_obj.items ||= [] | |||
@_obj.items.push item | |||
itemFun.call new exports.Item(item) | |||
query: (queryFun)-> | |||
query = {} | |||
@_obj.queries ||= [] | |||
@_obj.queries.push query | |||
queryFun.call new exports.Query(query) | |||
template: (templateFun)-> | |||
@_obj.template = {} | |||
templateFun.call new exports.Template(@_obj.template) | |||
|
|||
exports.Item = class Item extends exports.Data | |||
link: (options)-> | |||
@_obj.links ||= [] | |||
@_obj.links.push options | |||
|
|||
exports.Query = class Query extends exports.Data | |||
rel: (value)-> | |||
@_obj.rel = value | |||
|
|||
exports.Template = class Template extends exports.Data |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters