persistize 0.0.3 → 0.0.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/lib/persistize.rb CHANGED
@@ -47,7 +47,7 @@ module Persistize
47
47
  private
48
48
 
49
49
  def generate_callback(association, update_method)
50
- callback_name = :"#{update_method}_in_#{self.to_s.underscore}_callback"
50
+ callback_name = :"#{update_method}_in_#{self.to_s.underscore.gsub(/\W/, '_')}_callback"
51
51
  association_type = "#{association.macro}#{'_through' if association.through_reflection}"
52
52
  generate_method = :"generate_#{association_type}_callback"
53
53
  unless respond_to?(generate_method, true)
@@ -0,0 +1,3 @@
1
+ class Thing < ActiveRecord::Base
2
+
3
+ end
@@ -0,0 +1,8 @@
1
+ class Wadus::Thing < ActiveRecord::Base
2
+ set_table_name :wadus_things
3
+ has_many :things, :class_name => "::Thing", :foreign_key => "wadus_thing_id"
4
+ def summary
5
+ things.map(&:name).join(", ")
6
+ end
7
+ persistize :summary, :depending_on => :things
8
+ end
@@ -109,6 +109,16 @@ class PersistizeTest < Test::Unit::TestCase
109
109
  assert_equal("Enjuto Mojamuto has 3 tasks in 2 projects", @person.reload[:info])
110
110
  end
111
111
  end
112
+
113
+ context "namespaced models" do
114
+
115
+ should "access to namespaced models" do
116
+ @thing = Wadus::Thing.create
117
+ 2.times { |i| @thing.things.create(:name => "Thing number #{i + 1}") }
118
+ assert_equal("Thing number 1, Thing number 2", @thing.reload[:summary])
119
+ end
120
+
121
+ end
112
122
 
113
123
  end
114
124
 
data/test/test_helper.rb CHANGED
@@ -31,6 +31,13 @@ def setup_db
31
31
  create_table :companies do |t|
32
32
  t.string :name, :summary
33
33
  end
34
+ create_table :wadus_things do |t|
35
+ t.string :summary
36
+ end
37
+ create_table :things do |t|
38
+ t.integer :wadus_thing_id
39
+ t.string :name
40
+ end
34
41
  end
35
42
  end
36
43
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Gil
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-29 00:00:00 +01:00
13
+ date: 2009-12-29 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -35,6 +35,8 @@ files:
35
35
  - test/models/person.rb
36
36
  - test/models/project.rb
37
37
  - test/models/task.rb
38
+ - test/models/thing.rb
39
+ - test/models/wadus/thing.rb
38
40
  - test/persistize_test.rb
39
41
  - test/test_helper.rb
40
42
  has_rdoc: true
@@ -70,5 +72,7 @@ test_files:
70
72
  - test/models/person.rb
71
73
  - test/models/project.rb
72
74
  - test/models/task.rb
75
+ - test/models/thing.rb
76
+ - test/models/wadus/thing.rb
73
77
  - test/persistize_test.rb
74
78
  - test/test_helper.rb