comparison src/implab/di/ValueDescriptor.js @ 0:fc2517695ee1

Initial commit, draft import of existing work
author cin
date Thu, 01 Jun 2017 13:20:03 +0300
parents
children 93fb6c09f2e1
comparison
equal deleted inserted replaced
-1:000000000000 0:fc2517695ee1
1 define([ "dojo/_base/declare", "./Descriptor", "../safe" ],
2
3 function(declare, Descriptor, safe) {
4 return declare(Descriptor, {
5 _value : undefined,
6 _raw : false,
7 constructor : function(value, raw) {
8 this._value = value;
9 this._raw = Boolean(raw);
10 },
11
12 activate : function(context, name) {
13 context.enter(name, this);
14 var v = this._raw ? this._value : context.parse(
15 this._value,
16 ".params");
17 context.leave(this);
18 return v;
19 },
20
21 isInstanceCreated : function() {
22 return this._raw;
23 },
24
25 getInstance : function() {
26 if (!this._raw)
27 throw new Error("The instance isn't constructed");
28 return this._value;
29 },
30
31 toString : function() {
32 if (this._raw)
33 return "@value {raw}";
34 else
35 return safe.isNull(this._value) ? "@value <null>" : "@value";
36 }
37 });
38 });