vidibus-inheritance 0.3.14 → 0.3.15

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.0.0)
5
- activesupport (= 3.0.0)
4
+ activemodel (3.0.1)
5
+ activesupport (= 3.0.1)
6
6
  builder (~> 2.1.2)
7
7
  i18n (~> 0.4.1)
8
- activesupport (3.0.0)
9
- bson (1.0.4)
10
- bson_ext (1.0.7)
8
+ activesupport (3.0.1)
9
+ bson (1.1.1)
10
+ bson_ext (1.0.9)
11
11
  builder (2.1.2)
12
12
  diff-lcs (1.1.2)
13
13
  gemcutter (0.6.1)
@@ -19,33 +19,35 @@ GEM
19
19
  rubyforge (>= 2.0.0)
20
20
  json_pure (1.4.6)
21
21
  macaddr (1.0.0)
22
- mongo (1.0.7)
23
- bson (>= 1.0.4)
24
- mongoid (2.0.0.beta.17)
25
- activemodel (~> 3.0.0)
26
- bson (= 1.0.4)
27
- mongo (= 1.0.7)
22
+ mongo (1.0.9)
23
+ bson (>= 1.0.5)
24
+ mongoid (2.0.0.beta.19)
25
+ activemodel (~> 3.0)
26
+ mongo (= 1.0.9)
28
27
  tzinfo (~> 0.3.22)
29
28
  will_paginate (~> 3.0.pre)
30
29
  rake (0.8.7)
31
30
  relevance-rcov (0.9.2.1)
32
31
  rr (1.0.0)
33
- rspec (2.0.0.beta.20)
34
- rspec-core (= 2.0.0.beta.20)
35
- rspec-expectations (= 2.0.0.beta.20)
36
- rspec-mocks (= 2.0.0.beta.20)
37
- rspec-core (2.0.0.beta.20)
38
- rspec-expectations (2.0.0.beta.20)
32
+ rspec (2.0.1)
33
+ rspec-core (~> 2.0.1)
34
+ rspec-expectations (~> 2.0.1)
35
+ rspec-mocks (~> 2.0.1)
36
+ rspec-core (2.0.1)
37
+ rspec-expectations (2.0.1)
39
38
  diff-lcs (>= 1.1.2)
40
- rspec-mocks (2.0.0.beta.20)
39
+ rspec-mocks (2.0.1)
40
+ rspec-core (~> 2.0.1)
41
+ rspec-expectations (~> 2.0.1)
41
42
  rubyforge (2.0.4)
42
43
  json_pure (>= 1.1.7)
43
44
  tzinfo (0.3.23)
44
45
  uuid (2.3.1)
45
46
  macaddr (~> 1.0)
46
- vidibus-core_extensions (0.3.4)
47
- vidibus-uuid (0.3.6)
48
- uuid
47
+ vidibus-core_extensions (0.3.10)
48
+ vidibus-uuid (0.3.8)
49
+ mongoid (~> 2.0.0.beta.20)
50
+ uuid (~> 2.3.1)
49
51
  will_paginate (3.0.pre2)
50
52
 
51
53
  PLATFORMS
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gem.email = "andre@vidibus.com"
14
14
  gem.homepage = "http://github.com/vidibus/vidibus-inheritance"
15
15
  gem.authors = ["Andre Pankratz"]
16
- gem.add_dependency "mongoid", "~> 2.0.0.beta.17"
16
+ gem.add_dependency "mongoid", "~> 2.0.0.beta.20"
17
17
  gem.add_dependency "vidibus-core_extensions"
18
18
  gem.add_dependency "vidibus-uuid"
19
19
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.14
1
+ 0.3.15
@@ -24,8 +24,8 @@ module Vidibus
24
24
  validates :root_ancestor, :ancestor => true, :if => :root_ancestor_uuid?
25
25
 
26
26
  set_callback :validate, :before, :inherit_attributes, :if => :inherit?
27
- set_callback :save, :before, :track_mutations, :set_root_ancestor
28
- set_callback :save, :after, :postprocess
27
+ set_callback :save, :before, :track_mutations, :set_root_ancestor, :unless => :skip_inheritance?
28
+ set_callback :save, :after, :postprocess, :unless => :skip_inheritance?
29
29
  set_callback :destroy, :after, :destroy_inheritors
30
30
 
31
31
  # Returns true if attributes have been mutated.
@@ -227,7 +227,11 @@ module Vidibus
227
227
 
228
228
  # Performs actions after saving.
229
229
  def postprocess
230
- inherit_documents if inheritor? and embed?
230
+ if inheritor?
231
+ inherit_documents if embed?
232
+ # TODO: allow real callbacks
233
+ try!(:after_inheriting)
234
+ end
231
235
  update_inheritors
232
236
  end
233
237
 
@@ -240,7 +244,11 @@ module Vidibus
240
244
  def inherit?
241
245
  !_inherited and ancestor and (new_record? or ancestor_uuid_changed?)
242
246
  end
243
-
247
+
248
+ def skip_inheritance?
249
+ @skip_inheritance
250
+ end
251
+
244
252
  # Returns true if this documents has any inheritable documents.
245
253
  def embed?
246
254
  inheritable_documents.any?
@@ -440,4 +440,23 @@ describe "Inheritance" do
440
440
  end
441
441
  end
442
442
  end
443
+
444
+ context "with defined after callback" do
445
+ before do
446
+ any_instance_of(Model) do |m|
447
+ stub(m).after_inheriting {}
448
+ end
449
+ inheritor.inherit_from!(ancestor)
450
+ end
451
+
452
+ it "should call #after_inheriting on inheritor" do
453
+ any_instance_of(Model) {|m| mock(m).after_inheriting}
454
+ ancestor.save
455
+ end
456
+
457
+ it "should not call #after_inheriting on ancestor" do
458
+ dont_allow(ancestor).after_inheriting
459
+ ancestor.save
460
+ end
461
+ end
443
462
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vidibus-inheritance}
8
- s.version = "0.3.14"
8
+ s.version = "0.3.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Pankratz"]
12
- s.date = %q{2010-09-09}
12
+ s.date = %q{2010-10-22}
13
13
  s.description = %q{This gem allows inheritance of objects for Rails 3 with Mongoid. It will update all attributes and embedded documents of inheritors when ancestor gets changed.}
14
14
  s.email = %q{andre@vidibus.com}
15
15
  s.extra_rdoc_files = [
@@ -59,16 +59,16 @@ Gem::Specification.new do |s|
59
59
  s.specification_version = 3
60
60
 
61
61
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
- s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.beta.17"])
62
+ s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
63
63
  s.add_runtime_dependency(%q<vidibus-core_extensions>, [">= 0"])
64
64
  s.add_runtime_dependency(%q<vidibus-uuid>, [">= 0"])
65
65
  else
66
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.17"])
66
+ s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
67
67
  s.add_dependency(%q<vidibus-core_extensions>, [">= 0"])
68
68
  s.add_dependency(%q<vidibus-uuid>, [">= 0"])
69
69
  end
70
70
  else
71
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.17"])
71
+ s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
72
72
  s.add_dependency(%q<vidibus-core_extensions>, [">= 0"])
73
73
  s.add_dependency(%q<vidibus-uuid>, [">= 0"])
74
74
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidibus-inheritance
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 14
10
- version: 0.3.14
9
+ - 15
10
+ version: 0.3.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Pankratz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-09 00:00:00 +02:00
18
+ date: 2010-10-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,14 +26,14 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 62196417
29
+ hash: 62196427
30
30
  segments:
31
31
  - 2
32
32
  - 0
33
33
  - 0
34
34
  - beta
35
- - 17
36
- version: 2.0.0.beta.17
35
+ - 20
36
+ version: 2.0.0.beta.20
37
37
  type: :runtime
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency