active_preview 0.1.3 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e596b87c4f53216ef8eb93e095da11fff8399f39f0d7eafa5b9aa1d08db2392
4
- data.tar.gz: '049cbc159cbbcd5f11843704e2f68b9f84c29f41d0a9918a8fd63aebdb4ffcc1'
3
+ metadata.gz: fa0eff7423ed082c549f1cb8cb02eb8f374699eec3fff26ff1593c1bd4743b54
4
+ data.tar.gz: eed3a8642e9b2344f6effe820a3bc0b4bb206e9e130f5cdc2decaef0b2d27649
5
5
  SHA512:
6
- metadata.gz: f5e499eb31f2668b5f5ed2e9fb907e2f012cb8fd409ab0a367095e342468872c4bdf98f8dae2b3086876eeb4e5e37dfef379d237a04e728c909beab0b5a3790d
7
- data.tar.gz: 6ec6c1ae20d3130bf15680f7a5473f88c59f88bd5a9730ce4d38a12d2c39543c17acc05b7dabf5b3d5d497c8c8c52b5512e77537eadb4d449affa02f8b0ca011
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?(a)
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? "#{a}=" # avoid redefining methods
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)) {}
@@ -1,3 +1,3 @@
1
1
  module ActivePreview
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syd Young