Sha256: 156f7d551ba561d7826301a9ccd19e946a2198891b6b6e3d1cc1d4dad2d1048d
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
_.def("Luca.models.Component").extends("Luca.Model").with url: ()-> "/components?component=#{ @get('className') }" root: ()-> @get("className").split('.')[0] namespace: ()-> return "" unless @get("className")? parts = @get("className").split('.') parts.pop() parts.join "." _.def('Luca.collections.Components').extends('Luca.Collection').with model: Luca.models.Component cachedMethods: [ "namespaces" "classes" "roots" ] cache_key: "luca_components" name: "components" url: ()-> "/luca/components" initialize: (models, options)-> Luca.Collection.cache @cache_key, Luca.registry.classes() Luca.Collection::initialize.apply(@, arguments) classes: ()-> _.uniq( @pluck "className" ) roots: ()-> _.uniq( @invoke("root") ) namespaces: ()-> _.uniq( @invoke("namespace") ) asTree: ()-> classes = @classes() namespaces = @namespaces() roots = @roots() tree = _( roots ).inject (memo,root)-> memo[ root ] ||= {} regexp = new RegExp("^#{ root }") memo[root] = _( namespaces ).select (namespace)-> regexp.exec(namespace) and _( namespaces ).include(namespace) and namespace.split('.').length is 2 memo , {} _( tree ).inject (memo, namespaces, root)-> memo[root] = {} _( namespaces ).each (namespace)-> memo[root][namespace] = {} memo , {}
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
luca-0.9.2 | src/tools/models/components.coffee |
luca-0.9.1 | src/tools/models/components.coffee |
luca-0.9.0 | src/tools/models/components.coffee |