couchbase-patterns 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.
@@ -1,5 +1,5 @@
1
1
  module Couchbase
2
2
  module Patterns
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,7 +1,34 @@
1
1
  require "couchbase-patterns/version"
2
2
 
3
+ # active record verbs
4
+
5
+ # has_one
6
+ # 1..1 relationship between this object-document and another object-document
7
+ # coupled with belongs_to Company has_one :office, Office belongs_to Company
8
+
9
+ # has_many
10
+ # 1..n relationship between source object-document and another set of object-documents
11
+ # coupled with belongs_to Company has_many :employees, Employee belongs_to Company
12
+
13
+ # belongs_to
14
+ # has a foreign key to another object-document (coupled with has_one/has_many)
15
+
16
+ # has_and_belongs_to_many :categories
17
+
3
18
  module Couchbase
4
19
  module Patterns
5
- # Your code goes here...
20
+
21
+ # symbol-attributes to separate out as find_by methods,
22
+ # lookup attribute values MUST BE UNIQUE (i.e. email, phone number, uid, social network id, social security number, etc.)
23
+ def lookup_by(*attributes)
24
+ attributes.each do |a|
25
+ self.class.module_eval %Q{
26
+ def find_by_#{a} (&block)
27
+ yield(self) if block_given?
28
+ end
29
+ }
30
+ end # attributes.each
31
+ end # lookup_by
32
+
6
33
  end
7
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-patterns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ActiveRecord and Other Design Patterns for Models using Couchbase
15
15
  email: