sequel_couchbase_model 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +43 -1
- data/lib/sequel_couchbase_model.rb +1 -0
- data/lib/sequel_couchbase_model/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7385023745b1858951601e1b31d0d9afedef4a79
|
4
|
+
data.tar.gz: 356d70c677ecab48ef43cbfacf5a786184320a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b739ed44418fd6700b0f3356e0ea0d47d11b1f323559b87d02d163c9f2b21f75168514426f5164b98b44e3e354a62ff41e84fe9353004e969b710aeb779cdc47
|
7
|
+
data.tar.gz: db410b48d7d7d9238d60cb901cb692bf147dbd429505bc9aa607f146fd054882d91f01c6e36f14f032524fe8c8fa66d60c136d8f793f4f92ad567cc58cfbd0c2
|
data/README.md
CHANGED
@@ -1,6 +1,48 @@
|
|
1
1
|
# SequelCouchbaseModel
|
2
2
|
|
3
|
-
|
3
|
+
This gem is designed for people who are using both the couchbase-model and sequel gems and would like to use sequel model logic
|
4
|
+
in their couchbase models. This gem is still in beta stage, but right now it has preliminary support for sequel validations and
|
5
|
+
a few sequel hooks. To use it, your couchbase models must inherit Sequel::Couchbase::Model.
|
6
|
+
|
7
|
+
## Example
|
8
|
+
|
9
|
+
class VideoWatch < Sequel::Couchbase::Model
|
10
|
+
attribute :title
|
11
|
+
attribute :a
|
12
|
+
attribute :b
|
13
|
+
attribute :milliseconds_watched
|
14
|
+
attribute :created_at
|
15
|
+
attribute :updated_at
|
16
|
+
|
17
|
+
plugin :validation_helpers
|
18
|
+
|
19
|
+
def before_validate
|
20
|
+
self.milliseconds_watched ||= 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate
|
24
|
+
validates_presence [:title, :updated_at, :created_at, :milliseconds_watched]
|
25
|
+
validates_type String, :title
|
26
|
+
validates_type Fixnum, [:a, :b, :milliseconds_watched]
|
27
|
+
if a.blank? && b.blank?
|
28
|
+
errors.add :base, "At least one of a or b must be filled out!"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def before_save
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
......
|
37
|
+
rest of your logic
|
38
|
+
......
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
4
46
|
|
5
47
|
## Installation
|
6
48
|
|