theo-rails 0.4.6 → 0.4.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/theo-rails/theo.rb +6 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82b7eb29247e37f56eb09e03b7add260053723077d0bcd65ed7259ee3016c581
4
- data.tar.gz: 2713bda5ee620ebc85ab902fcc355591da97e3a9fd28d0748a47d7684cd1c0eb
3
+ metadata.gz: 1a9443aa5754585dfb06912767c3fe5e8431000789b2be5cf8e537f1246b0cd5
4
+ data.tar.gz: 487b9b3d1720d687a124c23a362899d19de7092755166148797f58cfbd170d23
5
5
  SHA512:
6
- metadata.gz: a50a0276165296cab5937ae6182fb50589173936b5554f938f905258270b3cdfa24f89a76d976a865faefb533f5ee1ba793e76afd01df2791a791ebdabe2faee
7
- data.tar.gz: 7c296d68417ec81a64b359afcec0b9bb4c20322208c82e9042556a2a4beabcc9b3c7332b9c1ff9e0d3ad62c387d7990d9ddc472a269ff4d4691c73b6ebbb934f
6
+ metadata.gz: 357b54e6e585fd4c199cc50be7e2bdfd048acc8ec57cf4d444243fa3a72cf8e2e7b337886588fc400cae87ff5e0f527bd723cc92195d1c5550e2dabae4d52299
7
+ data.tar.gz: 4402ff4139b35beb4cc3df13274217c630773a61ded30039bcb29e813671d26d5ed6c9647cd2875cb90f6c4d30febfeb779fb3bbe8e488ec844b861598f8dd7a
@@ -46,8 +46,8 @@ module Theo
46
46
 
47
47
  locals = attributes.empty? ? '' : attributes.map { |k, v| "'#{k}': #{v}" }.join(', ')
48
48
 
49
- is_component = view_component_exists?(partial)
50
- is_partial = !is_component
49
+ component = resolve_view_component(partial)
50
+ is_partial = component.nil?
51
51
 
52
52
  if is_partial
53
53
  partial = partial.delete_prefix('_').underscore
@@ -65,8 +65,6 @@ module Theo
65
65
  output = "<%= render partial: '#{partial}'#{collection}#{locals} %>"
66
66
  end
67
67
  else
68
- component = "#{partial}Component"
69
-
70
68
  if content
71
69
  output = "<%= render #{component}.new(#{locals}) do#{yields} %>#{process(content)}<% end %>"
72
70
  elsif collection
@@ -107,11 +105,12 @@ module Theo
107
105
  @view_component_loaded ||= Object.const_defined?('ViewComponent')
108
106
  end
109
107
 
110
- def view_component_exists?(component)
108
+ def resolve_view_component(component)
111
109
  return unless view_component_loaded?
112
110
 
113
- is_capitalized = /^[A-Z]/.match?(component)
114
- is_capitalized && Object.const_defined?("#{component}Component")
111
+ # safe_constantize ensures PascalCase
112
+ klass = component.safe_constantize || "#{component}Component".safe_constantize
113
+ klass.name if klass && klass < ViewComponent::Base
115
114
  end
116
115
 
117
116
  def translate_location(spot, backtrace_location, source)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: theo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarek Lipski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-10 00:00:00.000000000 Z
11
+ date: 2025-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport