active_preview 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_preview/builder.rb +3 -1
- data/lib/active_preview/preview.rb +7 -1
- data/lib/active_preview/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa0eff7423ed082c549f1cb8cb02eb8f374699eec3fff26ff1593c1bd4743b54
|
4
|
+
data.tar.gz: eed3a8642e9b2344f6effe820a3bc0b4bb206e9e130f5cdc2decaef0b2d27649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3102cad76553d2d26884c82c8e9f861d3e474690cc1d07a3e45eedf391b166780f5209b1928fff12b3fb58d5c5abe26bee9f126d9d7c5e881d6d3dd8902bfdd7
|
7
|
+
data.tar.gz: 3579c8ac488d465b7f7cdbce5037eaad84bf25a183aa39221344875034da1051ad0805e432a0b51492ae8c77cd1074459239dbb7f181f0a13c83205fb0531300
|
@@ -37,6 +37,7 @@ module ActivePreview
|
|
37
37
|
def update_associations
|
38
38
|
@updated_associations ||= child_params_keys.map do |params_key|
|
39
39
|
association_from_key(params_key).tap do |a|
|
40
|
+
next if preview.ignored_associations.include? a
|
40
41
|
preview.send("#{a}=", build_children(params_key, a))
|
41
42
|
end
|
42
43
|
end
|
@@ -70,7 +71,8 @@ module ActivePreview
|
|
70
71
|
|
71
72
|
def load_associations
|
72
73
|
associations(klass).each do |a|
|
73
|
-
next if updated_associations.include?
|
74
|
+
next if updated_associations.include? a
|
75
|
+
next if preview.ignored_associations.include? a
|
74
76
|
saved = [*model.send(a)]
|
75
77
|
next if saved.empty?
|
76
78
|
to_assign = BatchBuilder.build(klass: saved.first.class,
|
@@ -14,6 +14,12 @@ module ActivePreview
|
|
14
14
|
__getobj__
|
15
15
|
end
|
16
16
|
|
17
|
+
# Override in model-specific preview classes to disable previewing
|
18
|
+
# of certain associations
|
19
|
+
def ignored_associations
|
20
|
+
%w().freeze
|
21
|
+
end
|
22
|
+
|
17
23
|
# ~ used in place of association names
|
18
24
|
SINGULAR = %w(create_~ create_~! reload_~)
|
19
25
|
COLLECTION = %w(~_id ~_id= ~<<)
|
@@ -22,7 +28,7 @@ module ActivePreview
|
|
22
28
|
|
23
29
|
def redefine_associations(record)
|
24
30
|
associations(record.class).each do |a|
|
25
|
-
next if respond_to?
|
31
|
+
next if ignored_associations.include?(a) || respond_to?("#{a}=")
|
26
32
|
methods = singular?(a) ? SINGULAR : COLLECTION
|
27
33
|
methods.each do |method|
|
28
34
|
self.class.send(:define_method, method.gsub("~", a)) {}
|