README.markdown in couchpillow-0.3.0 vs README.markdown in couchpillow-0.3.1
- old
+ new
@@ -1,24 +1,27 @@
# CouchPillow
-Light and comfortable Document wrapper for Couchbase Server.
+Light and comfortable Document wrapper and integrity tool for Couchbase Server.
## Why CouchPillow?
-Yet another ORM? Not quite. CouchPillow separates itself from the database
-drivers, making it light and independent from the implementation.
+Yet another ORM? Not quite. CouchPillow is a wrapper to Couchbase Documents
+and also an integrity tool to make sure that all current and existing documents
+can work nicely with the current code.
-Although it is initially designed to work with Couchbase Server, one can
-easily extend this to other NoSQL drivers as long as they `respond_to?`
-the `set`, `delete`, `replace`, and `get` methods.
+CouchPillow separates itself from the database drivers, making it light and
+independent from the implementation. Although it is initially designed to work
+with Couchbase Server, one can easily extend this to other NoSQL drivers as
+long as they `respond_to?` the `set`, `delete`, `replace`, and `get` methods.
## Features
-- Automatic timestamp
-- Validation
+- Automatic id generation.
+- Automatic timestamp.
+- Built-in and custom data validations.
## Installation
gem install couchpillow
@@ -38,17 +41,17 @@
# 'created_at': '2014-07-04 00:00:00 UTC'
# 'updated_at': '2014-07-04 00:00:00 UTC'
# }
-Retrieving Documents
+Retrieving Documents:
doc = CouchPillow::Document.get('123')
doc.stuff # '123'
-Overriding `CouchPillow::Document`
+Overriding `CouchPillow::Document`:
class User < CouchPillow::Document
type :user
end
@@ -63,11 +66,11 @@
# 'email': 'john@email.com',
# 'created_at': '2014-07-04 00:00:00 UTC'
# 'updated_at': '2014-07-04 00:00:00 UTC'
# }
-Using validation
+Using built-in validation methods:
class User < CouchPillow::Document
type :user
validate_presence :email
validate_type :first_name, String
@@ -77,21 +80,18 @@
doc = User.new( { :first_name => 'John' } )
doc.save! # raises ValidationError('email is missing')
doc.email = 'john@email.com'
doc.save! # Success!
-Using custom validation blocks
+Using custom validation blocks:
class User < CouchPillow::Document
type :user
- validate_presence :email
validate :phone, 'is not a number', lambda { |v| v.is_a? Numeric }
end
CouchPillow.db = Couchbase.connect( bucket: 'default', host: 'localhost' )
doc = User.new
- doc.email = 'john@email.com'
- doc.first_name = 'john'
doc.phone = '123'
doc.save! # raises ValidationError('phone is not a number')
doc.phone = 123
doc.save! # Success!