Created
February 9, 2012 19:15
-
-
Save chrisconley/1782181 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
value: Ember.computed(function(key, value){ | |
if (arguments.length === 1) { // getter | |
var _value = this.get("_value"); | |
if (Ember.empty(_value)) { | |
return this.compileAttribute("initialValue"); | |
} | |
else { | |
return _value; | |
} | |
} | |
else { // setter | |
this.set('_value', value); | |
} | |
}).property('_value', 'initialValue') | |
myObject.set('value', '123'); | |
myObject.get('value'); // => '123' |
This file contains hidden or 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
def value | |
@value ||= load_default_value | |
end | |
def value=(str) | |
@value = str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment