Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Rename and expose instance variable via method

Aaron Contreras9bbfbe00d87e
diff --git a/app/components/concerns/op_turbo/streamable.rb b/app/components/concerns/op_turbo/streamable.rb
index d3e506a461d..a2911d2ca06 100644
--- a/app/components/concerns/op_turbo/streamable.rb
+++ b/app/components/concerns/op_turbo/streamable.rb
@@ -52,7 +52,7 @@ module OpTurbo
raise "Unsupported action #{action}"
end
- unless @component_wrapper_used
+ unless wrapped?
raise "You need to wrap your component in a `component_wrapper` block in order to use the turbo-stream methods"
end
@@ -66,7 +66,7 @@ module OpTurbo
def insert_as_turbo_stream(component:, view_context:, action: :append)
template = component.render_in(view_context)
- unless component.instance_variable_get(:@component_wrapper_used)
+ unless component.wrapped?
raise "You need to wrap your component in a `component_wrapper` block in order to use the turbo-stream methods"
end
@@ -78,7 +78,8 @@ module OpTurbo
end
def component_wrapper(tag: "div", class: nil, data: nil, style: nil, &block)
- @component_wrapper_used = true
+ @wrapped = true
+
if inner_html_only?
capture(&block)
elsif wrapper_only?
@@ -88,6 +89,10 @@ module OpTurbo
end
end
+ def wrapped?
+ !!@wrapped
+ end
+
def inner_html_only?
!!@inner_html_only
end