fides 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/fides/version.rb +1 -1
- data/lib/fides.rb +1 -0
- data/test/lib/fides/fides_test.rb +1 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2f7ad27b8fcf4775b3d93dbf0b81e92189d35cb
|
4
|
+
data.tar.gz: 80f98cbff22f202f192d171085026d1ffe334c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68a7524614d75f1632852a822fa042167d08a3b0cb8984e4f231fd2fd313a97b304992d8a827a16b63e70e0fb21159d1679af769aa130345fa3dfe5360dd522
|
7
|
+
data.tar.gz: 1e7488197348b392d03897830d57b4097ca9349d61fcd676ad1610282ef576fff53d096cdd06bc727d9499ba1f6b1992f2f6e138d5667afdb9db6c7159cf65a3
|
data/README.md
CHANGED
@@ -37,6 +37,22 @@ you would do the following in a migration:
|
|
37
37
|
|
38
38
|
class AddReferentialIntegrityToImageable < ActiveRecord::Migration
|
39
39
|
|
40
|
+
def up
|
41
|
+
add_polymorphic_triggers(:polymorphic_model => "Picture", :associated_models => ["Employee", "Product"])
|
42
|
+
end
|
43
|
+
|
44
|
+
def down
|
45
|
+
remove_polymorphic_triggers(:polymorphic_model => "Picture")
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
If you're using Rails < version 3.1, then use Fides in your migration like this:
|
51
|
+
|
52
|
+
class AddReferentialIntegrityToImageable < ActiveRecord::Migration
|
53
|
+
|
54
|
+
extend Fides
|
55
|
+
|
40
56
|
def self.up
|
41
57
|
add_polymorphic_triggers(:polymorphic_model => "Picture", :associated_models => ["Employee", "Product"])
|
42
58
|
end
|
data/lib/fides/version.rb
CHANGED
data/lib/fides.rb
CHANGED
@@ -21,6 +21,7 @@ module Fides
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def remove_polymorphic_triggers(opts)
|
24
|
+
raise ArgumentError, "missing :polymorphic_model from options hash" if !opts.has_key?(:polymorphic_model)
|
24
25
|
polymorphic_model = opts[:polymorphic_model]
|
25
26
|
interface_name = opts.has_key?(:interface_name) ? opts[:interface_name] : interface_name(polymorphic_model)
|
26
27
|
|
@@ -5,15 +5,7 @@ describe Fides do
|
|
5
5
|
before do
|
6
6
|
class Picture < ActiveRecord::Base; end
|
7
7
|
class MyTestMigration < ActiveRecord::Migration; end
|
8
|
-
class MyTestAssociaiton
|
9
|
-
def options
|
10
|
-
{ :polymorphic => true }
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
"imageable"
|
15
|
-
end
|
16
|
-
end
|
8
|
+
class MyTestAssociaiton; end
|
17
9
|
@my_test_association = MyTestAssociaiton.new
|
18
10
|
@my_test_migration = MyTestMigration.new
|
19
11
|
end
|