Skip to content

Commit

Permalink
fixing docs on partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
larsburgess committed Mar 4, 2011
1 parent baca514 commit 6d52a71
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,35 @@ Note, if you are using datamapper, install the `dm-serializer` library and requi
## Usage
Now include Rhosync::Resource in a model that you want to synchronize with your mobile application:

class User < ActiveRecord::Base
class Product < ActiveRecord::Base
include Rhosync::Resource
end

Or, if you are using DataMapper:

class User
class Product
include DataMapper::Resource
include Rhosync::Resource
end

Next, your models will need to declare a partition key for `rhosync-rb`. This partition key is used by `rhosync-rb` to uniquely identify the model dataset when it is stored in a RhoSync application. It is typically an attribute on the model or related model. `rhosync-rb` supports three types of partitions:
Next, your models will need to declare a partition key for `rhosync-rb`. This partition key is used by `rhosync-rb` to uniquely identify the model dataset when it is stored in a RhoSync application. It is typically an attribute on the model or related model. `rhosync-rb` supports two types of partitions:

* :app - no unique key will be used, a single dataset is used for all users
* { some lambda } - execute a block which returns the key string
* :app - No unique key will be used, a shared dataset is used for all users.
* lambda { some lambda } - Execute a lambda which returns the unique key string.

For example, the `User` model above might have a 'username' attribute. The partition would be declared as:
For example, the `Product` model above might have a `belongs_to :user` relationship. The partition identifying the username would be declared as:

class User < ActiveRecord::Base
class Product < ActiveRecord::Base
include Rhosync::Resource
belongs_to :user

partition { self.username }
partition lambda { self.user.username }
end

For more information about RhoSync partitions, please refer to the [RhoSync docs](http://docs.rhomobile.com/rhosync/source-adapters#data-partitioning).

## Meta
Created and maintained by Vladimir Tarasov and Lars Burgess.

Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

0 comments on commit 6d52a71

Please sign in to comment.