Skip to content

Instantly share code, notes, and snippets.

@chrisconley
Created February 9, 2012 19:15
Show Gist options
  • Save chrisconley/1782181 to your computer and use it in GitHub Desktop.
Save chrisconley/1782181 to your computer and use it in GitHub Desktop.
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'
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