Sha256: b9d9397add7cb6f021f1351e1e8188cebee16162883331cfbde0ab47be4564bc
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
Shuriken.defineExtension (baseNS) -> baseNS.withNS 'Mixins', (ns) -> root = @getRootNS() ns.mixins = {} root.mixins = {} root.withBase (base) -> base.mixin = (mixins) -> ns.mixin @, mixins defineMixin = (key, mixin) -> @mixins[key] = mixin root.defineMixin = defineMixin ns.define = defineMixin ns.lookupMixin = (mixin) -> switch typeof mixin when "string" if ns.mixins[mixin]? ns.mixins[mixin] else if root.mixins[mixin]? root.mixins[mixin] else {} # unknown mixin, return a blank object. else mixin ns.invokeMixin = (scope, mixin) -> switch typeof mixin when "string" ns.invokeMixin scope, ns.lookupMixin(mixin) when "function" mixin.call scope, scope when "object" $.extend scope, mixin ns.mixin = (scope, mixins) -> mixins = [mixins] unless $.isArray mixins ns.invokeMixin scope, ns.lookupMixin(mixin) for mixin in mixins true
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shuriken-0.2.1 | coffeescripts/shuriken/mixins.coffee |