langalex-couch_potato 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml
CHANGED
@@ -29,9 +29,7 @@ module CouchPotato
|
|
29
29
|
|
30
30
|
def json_create(json) #:nodoc:
|
31
31
|
instance = super
|
32
|
-
instance.
|
33
|
-
instance.instance_variable_set("@#{name}_was", value)
|
34
|
-
end
|
32
|
+
instance.send(:assign_attribute_copies_for_dirty_tracking)
|
35
33
|
instance
|
36
34
|
end
|
37
35
|
|
@@ -11,10 +11,23 @@ module CouchPotato
|
|
11
11
|
|
12
12
|
def initialize(attributes = {})
|
13
13
|
super attributes
|
14
|
+
assign_attribute_copies_for_dirty_tracking
|
15
|
+
end
|
16
|
+
|
17
|
+
def assign_attribute_copies_for_dirty_tracking
|
14
18
|
attributes.each do |name, value|
|
15
|
-
self.instance_variable_set("@#{name}_was", value)
|
19
|
+
self.instance_variable_set("@#{name}_was", clone_attribute(value))
|
16
20
|
end if attributes
|
17
21
|
end
|
22
|
+
private :assign_attribute_copies_for_dirty_tracking
|
23
|
+
|
24
|
+
def clone_attribute(value)
|
25
|
+
if [Fixnum, Symbol, TrueClass, FalseClass, NilClass, Float].include?(value.class)
|
26
|
+
value
|
27
|
+
else
|
28
|
+
value.clone
|
29
|
+
end
|
30
|
+
end
|
18
31
|
|
19
32
|
define_method "#{name}=" do |value|
|
20
33
|
self.instance_variable_set("@#{name}", value)
|
@@ -84,6 +84,13 @@ describe 'dirty attribute tracking' do
|
|
84
84
|
@plate.food = 'burger'
|
85
85
|
@plate.should be_food_changed
|
86
86
|
end
|
87
|
+
|
88
|
+
it "should return true if array attribute changed" do
|
89
|
+
couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => ['sushi'], 'ruby_class' => 'Plate'}, :info => nil)
|
90
|
+
plate = CouchPotato::Database.new(couchrest_db).load_document '1'
|
91
|
+
plate.food << 'burger'
|
92
|
+
plate.should be_food_changed
|
93
|
+
end
|
87
94
|
|
88
95
|
it "should return false if attribute not changed" do
|
89
96
|
@plate.should_not be_food_changed
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: langalex-couch_potato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -54,14 +54,14 @@ files:
|
|
54
54
|
- MIT-LICENSE.txt
|
55
55
|
- README.md
|
56
56
|
- VERSION.yml
|
57
|
-
-
|
57
|
+
- init.rb
|
58
58
|
- lib/core_ext/date.rb
|
59
59
|
- lib/core_ext/object.rb
|
60
60
|
- lib/core_ext/string.rb
|
61
61
|
- lib/core_ext/time.rb
|
62
|
-
- lib/couch_potato
|
62
|
+
- lib/couch_potato.rb
|
63
63
|
- lib/couch_potato/database.rb
|
64
|
-
- lib/couch_potato/persistence
|
64
|
+
- lib/couch_potato/persistence.rb
|
65
65
|
- lib/couch_potato/persistence/belongs_to_property.rb
|
66
66
|
- lib/couch_potato/persistence/callbacks.rb
|
67
67
|
- lib/couch_potato/persistence/dirty_attributes.rb
|
@@ -69,8 +69,6 @@ files:
|
|
69
69
|
- lib/couch_potato/persistence/magic_timestamps.rb
|
70
70
|
- lib/couch_potato/persistence/properties.rb
|
71
71
|
- lib/couch_potato/persistence/simple_property.rb
|
72
|
-
- lib/couch_potato/persistence.rb
|
73
|
-
- lib/couch_potato/view
|
74
72
|
- lib/couch_potato/view/base_view_spec.rb
|
75
73
|
- lib/couch_potato/view/custom_view_spec.rb
|
76
74
|
- lib/couch_potato/view/custom_views.rb
|
@@ -78,7 +76,7 @@ files:
|
|
78
76
|
- lib/couch_potato/view/properties_view_spec.rb
|
79
77
|
- lib/couch_potato/view/raw_view_spec.rb
|
80
78
|
- lib/couch_potato/view/view_query.rb
|
81
|
-
-
|
79
|
+
- rails/init.rb
|
82
80
|
- spec/callbacks_spec.rb
|
83
81
|
- spec/create_spec.rb
|
84
82
|
- spec/custom_view_spec.rb
|
@@ -86,7 +84,6 @@ files:
|
|
86
84
|
- spec/property_spec.rb
|
87
85
|
- spec/spec.opts
|
88
86
|
- spec/spec_helper.rb
|
89
|
-
- spec/unit
|
90
87
|
- spec/unit/attributes_spec.rb
|
91
88
|
- spec/unit/create_spec.rb
|
92
89
|
- spec/unit/database_spec.rb
|
@@ -94,13 +91,10 @@ files:
|
|
94
91
|
- spec/unit/string_spec.rb
|
95
92
|
- spec/unit/view_query_spec.rb
|
96
93
|
- spec/update_spec.rb
|
97
|
-
- rails/init.rb
|
98
|
-
- init.rb
|
99
94
|
has_rdoc: true
|
100
95
|
homepage: http://github.com/langalex/couch_potato
|
101
96
|
post_install_message:
|
102
97
|
rdoc_options:
|
103
|
-
- --inline-source
|
104
98
|
- --charset=UTF-8
|
105
99
|
require_paths:
|
106
100
|
- lib
|
@@ -123,5 +117,17 @@ rubygems_version: 1.2.0
|
|
123
117
|
signing_key:
|
124
118
|
specification_version: 2
|
125
119
|
summary: Ruby persistence layer for CouchDB
|
126
|
-
test_files:
|
127
|
-
|
120
|
+
test_files:
|
121
|
+
- spec/callbacks_spec.rb
|
122
|
+
- spec/create_spec.rb
|
123
|
+
- spec/custom_view_spec.rb
|
124
|
+
- spec/destroy_spec.rb
|
125
|
+
- spec/property_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/unit/attributes_spec.rb
|
128
|
+
- spec/unit/create_spec.rb
|
129
|
+
- spec/unit/database_spec.rb
|
130
|
+
- spec/unit/dirty_attributes_spec.rb
|
131
|
+
- spec/unit/string_spec.rb
|
132
|
+
- spec/unit/view_query_spec.rb
|
133
|
+
- spec/update_spec.rb
|