Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sugar for Ember Objects.
JavaScript Ruby
tree: 3c39592b5b

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs
generators
packages/ember-ohm
tests
.gitignore
.jshintrc
.ruby-version
.travis.yml
Assetfile
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
VERSION
config.ru
ember-dev.yml

README.md

ember-ohm Build Status

Ember.Object Models. You bring the AJAX, we bring attributes, array attributes and attribute change tracking.

Build

Ruby is required to be installed on your system. Once that's setup, run the following:

gem install bundler
git clone git://github.com/bschaeffer/ember-ohm.git
cd ember-ohm
bundle install
bundle exec rake dist

Example

App.User = Ohm.Model.extend({
  name: Atts.attr()
});

user = App.User.create({name: 'John'});

// Attribute Methods
user.getAttributeKeys(); // ['name']
user.getAttributes();    // {name: 'John'}

// Default state.
user.get('name');            // John
user.get('isDirty');         // false
user.get('isClean');         // true
user.get('name_changed');    // false
user.getChangedKeys();       // []
user.getChangedProperties(); // {}

// Changed state.
user.set('name', 'Bob');
user.get('name');            // Bob
user.get('isDirty');         // true
user.get('isClean');         // false
user.get('name_changed');    // true
user.getChangedKeys();       // ['name']
user.getChangedProperties(); // {name: 'Bob'}

// Revert changed state.
user.revert();
user.get('name');            // John
user.get('isDirty');         // false
user.get('isClean');         // true
user.get('name_changed');    // false
user.getChangedKeys();       // []
user.getChangedProperties(); // {}

// Commit changed state.
user.set('name', 'Ralph');
user.commit();
user.get('name');            // Raplh
user.get('isDirty');         // false
user.get('isClean');         // true
user.get('name_changed');    // false
user.getChangedKeys();       // []
user.getChangedProperties(); // {}
Something went wrong with that request. Please try again.