Skip to content

Commit

Permalink
Move methods to private section
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitkkr committed Jan 28, 2023
1 parent 70cd5a1 commit a48c46d
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,6 @@ def react_component(component_name, options = {})
end
end

def load_pack_for_component(component_name)
is_component_pack_present = File.exist?(generated_components_pack_path(component_name))
is_development = ENV["RAILS_ENV"] == "development"

if is_development && !is_component_pack_present
ReactOnRails::PacksGenerator.generate
raise_missing_pack_error(component_name)
end

ReactOnRails::PacksGenerator.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries?

append_javascript_pack_tag "generated/#{component_name}"
append_stylesheet_pack_tag "generated/#{component_name}"
end

def generated_components_pack_path(component_name)
extension = PacksGenerator::GENERATED_PACK_EXTENSION

"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}"
end

# react_component_hash is used to return multiple HTML strings for server rendering, such as for
# adding meta-tags to a page.
# It is exactly like react_component except for the following:
Expand Down Expand Up @@ -340,6 +319,27 @@ def rails_context(server_side: true)

private

def load_pack_for_component(component_name)
is_component_pack_present = File.exist?(generated_components_pack_path(component_name))
is_development = ENV["RAILS_ENV"] == "development"

if is_development && !is_component_pack_present
ReactOnRails::PacksGenerator.generate
raise_missing_pack_error(component_name)
end

ReactOnRails::PacksGenerator.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries?

append_javascript_pack_tag "generated/#{component_name}"
append_stylesheet_pack_tag "generated/#{component_name}"
end

def generated_components_pack_path(component_name)
extension = PacksGenerator::GENERATED_PACK_EXTENSION

"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}"
end

def build_react_component_result_for_server_rendered_string(
server_rendered_html: required("server_rendered_html"),
component_specification_tag: required("component_specification_tag"),
Expand Down

0 comments on commit a48c46d

Please sign in to comment.