memories 0.2.2 → 0.2.3

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.
data/README.markdown CHANGED
@@ -7,6 +7,10 @@ stored as an attachment on the document. This versioning strategy was originally
7
7
 
8
8
  $ gem install memories
9
9
 
10
+ ## Documentation
11
+
12
+ Browse the documentation on rdoc.info: http://rdoc.info/github/moonmaster9000/memories
13
+
10
14
  ##How does it work?
11
15
 
12
16
  Just "include Memories" in your "CouchRest::Model::Base" classes and let the auto-versioning begin.
@@ -61,6 +65,7 @@ If you'd like to exclude certain properties from versioning, use the #forget cla
61
65
  p b.notes # ==> "creating the book. updating the title. might ship today. 9/2/2010. MKP"
62
66
  b.current_version #==> 3
63
67
 
68
+ If you'd like to explicitly define which properties to version, use the #remember method. It works just like #forget, but in reverse. Duh.
64
69
 
65
70
  ###Milestones
66
71
 
data/README.rdoc CHANGED
@@ -7,6 +7,10 @@ stored as an attachment on the document. This versioning strategy was originally
7
7
 
8
8
  $ gem install memories
9
9
 
10
+ == Documentation
11
+
12
+ Browse the documentation on rdoc.info: http://rdoc.info/github/moonmaster9000/memories
13
+
10
14
  == How does it work?
11
15
 
12
16
  Just "include Memories" in your "CouchRest::Model::Base" classes and let the auto-versioning begin.
@@ -61,6 +65,8 @@ If you'd like to exclude certain properties from versioning, use the #forget cla
61
65
  p b.notes # ==> "creating the book. updating the title. might ship today. 9/2/2010. MKP"
62
66
  b.current_version #==> 3
63
67
 
68
+ If you'd like to explicitly define which properties to version, use the #remember method. It works just like #forget, but in reverse. Duh.
69
+
64
70
  === Milestones
65
71
 
66
72
  As of version 0.2.0, Memories also supports milestones. Milestones are special versions that you want to flag in some way.
data/lib/memories/base.rb CHANGED
@@ -17,6 +17,8 @@ module Memories
17
17
  #
18
18
  # class MyDocument < CouchRest::Model::Base
19
19
  # use_database MY_DATABASE
20
+ # include Memories
21
+ #
20
22
  # forget :prop1, :prop2
21
23
  #
22
24
  # property :prop1 #not versioned
@@ -24,9 +26,44 @@ module Memories
24
26
  # property :prop3 #versioned
25
27
  # end
26
28
  def forget(*props)
29
+ raise StandardError, "Ambiguous use of both #remember and #forget." if @remember_called
30
+ @forget_called = true
27
31
  self.forget_properties += props.map {|p| p.to_s}
28
32
  end
29
33
 
34
+
35
+ # If you'd like to explicitly define which properties you want versioned simply pass those properties
36
+ # to this method:
37
+ #
38
+ # class MyDocument < CouchRest::Model::Base
39
+ # use_database MY_DATABASE
40
+ # include Memories
41
+ #
42
+ # remember :prop1, :prop2
43
+ #
44
+ # property :prop1 #versioned
45
+ # property :prop2 #versioned
46
+ # property :prop3 # not versioned
47
+ # end
48
+ def remember(*props)
49
+ raise StandardError, "Ambiguous use of both #remember and #forget." if @forget_called
50
+ @remember_called = true
51
+ props = props.map {|p| p.to_s}
52
+ if self.remember_properties.nil?
53
+ self.remember_properties = props
54
+ else
55
+ self.remember_properties += props
56
+ end
57
+ end
58
+
59
+ def remember_properties #:nodoc
60
+ @remember_properties ||= nil
61
+ end
62
+
63
+ def remember_properties=(props) #:nodoc
64
+ @remember_properties = props
65
+ end
66
+
30
67
  def forget_properties #:nodoc:
31
68
  @forget_properties ||= ["couchrest-type", "_id", "_rev", "_attachments", "milestone_memories"]
32
69
  end
@@ -174,7 +211,11 @@ module Memories
174
211
  end
175
212
 
176
213
  def prep_for_versioning(doc)
177
- doc.dup.delete_if {|k,v| self.class.forget_properties.include? k}
214
+ if self.class.remember_properties.nil?
215
+ doc.dup.delete_if {|k,v| self.class.forget_properties.include? k}
216
+ else
217
+ doc.dup.delete_if {|k,v| !self.class.remember_properties.include?(k)}
218
+ end
178
219
  end
179
220
 
180
221
  def decode_attachments
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memories
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Parker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-04 00:00:00 -04:00
18
+ date: 2010-09-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency