Skip to content

Commit

Permalink
- added 'readable' and 'writeable' attributes to Joose.Managed.Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
canonic-epicure committed Feb 20, 2010
1 parent 3ffbf24 commit af2bb0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions lib/Joose/Managed/Attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
hasGetter : false,
hasSetter : false,

readable : false,
writeable : false,

required : false
},

Expand All @@ -31,8 +34,8 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
this.setterName = this.setterName || this.getSetterName()
this.getterName = this.getterName || this.getGetterName()

this.hasGetter = /^r/i.test(this.is)
this.hasSetter = /^rw/i.test(this.is)
this.readable = this.hasGetter = /^r/i.test(this.is)
this.writeable = this.hasSetter = /^.w/i.test(this.is)
}
},

Expand Down Expand Up @@ -132,7 +135,7 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
getValueFrom : function (instance) {
var getterName = this.getterName

if (this.hasGetter && instance.meta.hasMethod(getterName)) return instance[getterName]()
if (this.readable && instance.meta.hasMethod(getterName)) return instance[getterName]()

return instance[this.slot]
},
Expand All @@ -141,7 +144,7 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
setValueTo : function (instance, value) {
var setterName = this.setterName

if (this.hasSetter && instance.meta.hasMethod(setterName)) instance[setterName](value)
if (this.writeable && instance.meta.hasMethod(setterName)) instance[setterName](value)

instance[this.slot] = value
},
Expand Down
11 changes: 7 additions & 4 deletions lib/Task/Joose/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,9 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
hasGetter : false,
hasSetter : false,

readable : false,
writeable : false,

required : false
},

Expand All @@ -2490,8 +2493,8 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
this.setterName = this.setterName || this.getSetterName()
this.getterName = this.getterName || this.getGetterName()

this.hasGetter = /^r/i.test(this.is)
this.hasSetter = /^rw/i.test(this.is)
this.readable = this.hasGetter = /^r/i.test(this.is)
this.writeable = this.hasSetter = /^.w/i.test(this.is)
}
},

Expand Down Expand Up @@ -2591,7 +2594,7 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
getValueFrom : function (instance) {
var getterName = this.getterName

if (this.hasGetter && instance.meta.hasMethod(getterName)) return instance[getterName]()
if (this.readable && instance.meta.hasMethod(getterName)) return instance[getterName]()

return instance[this.slot]
},
Expand All @@ -2600,7 +2603,7 @@ Joose.Managed.Attribute = new Joose.Managed.Class('Joose.Managed.Attribute', {
setValueTo : function (instance, value) {
var setterName = this.setterName

if (this.hasSetter && instance.meta.hasMethod(setterName)) instance[setterName](value)
if (this.writeable && instance.meta.hasMethod(setterName)) instance[setterName](value)

instance[this.slot] = value
},
Expand Down

0 comments on commit af2bb0b

Please sign in to comment.