README.md in zermelo-1.0.0 vs README.md in zermelo-1.0.1
- old
+ new
@@ -40,11 +40,11 @@
Include **zermelo**'s Record module in the class you want to persist data from:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
end
```
and then create and save an instance of that class:
@@ -65,11 +65,11 @@
A data record without any actual data isn't very useful, so let's add a few simple data fields to the Post model:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
define_attributes :title => :string,
:score => :integer,
:timestamp => :timestamp,
:published => :boolean
end
@@ -114,11 +114,11 @@
So if we add tags to the Post data definition:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
define_attributes :title => :string,
:score => :integer,
:timestamp => :timestamp,
:published => :boolean,
:tags => :set
@@ -159,11 +159,11 @@
So an attribute which should be present:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
define_attributes :title => :string,
:score => :integer
validates :title, :presence => true
end
```
@@ -200,19 +200,19 @@
**Zermelo** will lock operations to ensure that changes are applied consistently. The locking code is based on [redis-lock](https://github.com/mlanett/redis-lock), but has been extended and customised to allow **zermelo** to lock more than one class at a time. Record saving and destroying is implicitly locked, while if you want to carry out complex queries or changes without worring about what else may be changing data at the same time, you can use the `lock` class method as follows:
```ruby
class Author
- include Zermelo:Record
+ include Zermelo::Record
end
class Post
- include Zermelo:Record
+ include Zermelo::Record
end
class Comment
- include Zermelo:Record
+ include Zermelo::Record
end
Author.lock(Post, Comment) do
# ... complicated data operations ...
end
@@ -222,11 +222,11 @@
Assuming a saved `Post` instance has been created:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
define_attributes :title => :string,
:score => :integer,
:timestamp => :timestamp,
:published => :boolean
end
@@ -301,16 +301,16 @@
| `belongs_to` | many-to-one or one-to-one | [HASH](http://redis.io/commands#hash) or [STRING](http://redis.io/commands#string) | Inverse of any of the above three |
| `has_and_belongs_to_many` | many-to-many | 2 [SET](http://redis.io/commands#set)s | Mirrored by an inverse HaBtM association on the other side. |
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
has_many :comments, :class_name => 'Comment', :inverse_of => :post
end
class Comment
- include Zermelo:Record
+ include Zermelo::Record
belongs_to :post, :class_name => 'Post', :inverse_of => :comments
end
```
Class names of the associated class are used, instead of a reference to the class itself, to avoid circular dependencies being established. The inverse association is provided in order that multiple associations between the same two classes can be created.
@@ -329,16 +329,16 @@
`has_one` associations are simply set with an `=` method on the association:
```ruby
class User
- include Zermelo:Record
+ include Zermelo::Record
has_one :preferences, :class_name => 'Preferences', :inverse_of => :user
end
class Preferences
- include Zermelo:Record
+ include Zermelo::Record
belongs_to :user, :class_name => 'User', :inverse_of => :preferences
end
user = User.new
user.save
@@ -396,10 +396,10 @@
Using the code from the instance attributes section, and adding indexing:
```ruby
class Post
- include Zermelo:Record
+ include Zermelo::Record
define_attributes :title => :string,
:score => :integer,
:timestamp => :timestamp,
:published => :boolean