view_component 2.26.0 → 2.26.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a1fb023bfaa4a1ea26166ddd22b5fcd4a7e5f5da1bc7f10039c2bc557f1a94c
4
- data.tar.gz: 5274b49f0e18f521b15181c70aeb4edcf3458cba13dc8c8ea59b9331d26681c5
3
+ metadata.gz: 071c4caebc8e0dd567d8850adff146e65f6c8c1fe600b866f072d9bfa94bbc46
4
+ data.tar.gz: 64df3c2eb8d27431da23a2c628de6c9c00d7988130494d37319f4a01d653fd9c
5
5
  SHA512:
6
- metadata.gz: fc60826197c5dbd54ebd53517ff59eab097449913802a4e17df9db33ab54d1daf8ff2e00d1629058962c267274ec7fe6e362aa036206d379e27c7c832db7d05c
7
- data.tar.gz: b3a65f7a829d9e9fc675904d61c6d1c1015c194c5a7abe596961b3cb20a3a4c2045f1ce49b1b98a551c4b745688c38610d3a86040c1f7f0229c3b247a51f9c65
6
+ metadata.gz: 69bc43697d70dfb9b96280f47b80c06d1020fd180c01cbc6ae8c8416c3e1b97ffc6587d00741fa81743ae482a316e653790db5af2584c16baf3839a58b809195
7
+ data.tar.gz: 636d5d91edb07cb90f44e3fc21e7ee63c3c115d1f5fbf7666619205b628761028c4963c65b30a181f27fbbd0bf9539cab0ec3271a48b4d747d7a705528218f11
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 2.26.1
6
+
7
+ * Fix bug that raises when trying to use a collection before the component has been compiled.
8
+
9
+ *Blake Williams*
10
+
5
11
  ## 2.26.0
6
12
 
7
13
  * Lazily evaluate component `content` in `render?`, preventing the `content` block from being evaluated when `render?` returns false.
@@ -324,6 +324,22 @@ module ViewComponent
324
324
  )
325
325
  end
326
326
 
327
+ def collection_parameter
328
+ if provided_collection_parameter
329
+ provided_collection_parameter
330
+ else
331
+ name && name.demodulize.underscore.chomp("_component").to_sym
332
+ end
333
+ end
334
+
335
+ def collection_counter_parameter
336
+ "#{collection_parameter}_counter".to_sym
337
+ end
338
+
339
+ def counter_argument_present?
340
+ instance_method(:initialize).parameters.map(&:second).include?(collection_counter_parameter)
341
+ end
342
+
327
343
  private
328
344
 
329
345
  def initialize_parameter_names
@@ -24,28 +24,6 @@ module ViewComponent
24
24
  )
25
25
  end
26
26
 
27
- # Remove any existing singleton methods,
28
- # as Ruby warns when redefining a method.
29
- component_class.remove_possible_singleton_method(:collection_parameter)
30
- component_class.remove_possible_singleton_method(:collection_counter_parameter)
31
- component_class.remove_possible_singleton_method(:counter_argument_present?)
32
-
33
- component_class.define_singleton_method(:collection_parameter) do
34
- if provided_collection_parameter
35
- provided_collection_parameter
36
- else
37
- name.demodulize.underscore.chomp("_component").to_sym
38
- end
39
- end
40
-
41
- component_class.define_singleton_method(:collection_counter_parameter) do
42
- "#{collection_parameter}_counter".to_sym
43
- end
44
-
45
- component_class.define_singleton_method(:counter_argument_present?) do
46
- instance_method(:initialize).parameters.map(&:second).include?(collection_counter_parameter)
47
- end
48
-
49
27
  if raise_errors
50
28
  component_class.validate_initialization_parameters!
51
29
  component_class.validate_collection_parameter!
@@ -28,7 +28,11 @@ module ViewComponent
28
28
  @content = view_context.capture do
29
29
  if defined?(@_component_instance)
30
30
  # render_in is faster than `parent.render`
31
- @_component_instance.render_in(view_context, &@_content_block)
31
+ if defined?(@_content_block)
32
+ @_component_instance.render_in(view_context, &@_content_block)
33
+ else
34
+ @_component_instance.render_in(view_context)
35
+ end
32
36
  elsif defined?(@_content)
33
37
  @_content
34
38
  elsif defined?(@_content_block)
@@ -4,7 +4,7 @@ module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 26
7
- PATCH = 0
7
+ PATCH = 1
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.26.0
4
+ version: 2.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport