Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sugar for Ember Objects.
JavaScript Ruby
tag: v0.1.3

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
builds
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

Simple attribute sugar for Ember.Object properties:

  • Attribute & array attribute serialization.
  • Attribute & array attribute change tracking.
  • Easy Ember.Object dirty management management.

Installation

You can grab a copy of the current version from the builds directory. If that doesn't work, you can build it yourself.

Documentation

Model & Attributes

Declaring an attribute via Ohm.attr and Ohm.arrayAttr gives you access to a few attribute related methods. Take the following model/object definition:

User = Ohm.Model.extend({
  name: Ohm.attr('string'),
  age:  Ohm.attr('number'),
});

user = User.create({
  name: 'Braden',
  age:  '23',
});

getAttributes

Returns the an object of attribute key: value pairs defined by the object class. Passing true as the second value returns serialized values for these attributes:

user.getAttributes();     // {name: 'Braden', age: '23'}
user.getAttributes(true); // {name: 'Braden', age: 23}

toggleCounter

Increments the given property based on the given value of toggle.

user.set('age', 23);
user.toggleCounter('age');             // 22
user.toggleCounter('age', false);      // 21
user.toggleCounter('age', true);       // 22
user.toggleCounter('age', 'anything'); // 23

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
Something went wrong with that request. Please try again.