Skip to content

Commit 4f22323

Browse files
committed
chore: a bit of refactoring
1 parent e5c4edf commit 4f22323

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

app/services/maglev/translate_page.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class TranslatePage
1616
def call
1717
return nil unless page.persisted?
1818

19-
translate_page!
19+
translate_all!
2020
end
2121

22-
private
22+
protected
2323

2424
def site
2525
@site ||= fetch_site.call
@@ -29,18 +29,20 @@ def theme
2929
@theme ||= fetch_theme.call
3030
end
3131

32-
protected
33-
34-
def translate_page!
32+
def translate_all!
3533
translate_page_attributes
3634
translate_all_sections
3735

36+
persist_changes!
37+
38+
page
39+
end
40+
41+
def persist_changes!
3842
ActiveRecord::Base.transaction do
3943
site.save!
4044
page.save!
4145
end
42-
43-
page
4446
end
4547

4648
def translate_page_attributes
@@ -119,12 +121,4 @@ def clone_array(array)
119121
Marshal.load(Marshal.dump(array || []))
120122
end
121123
end
122-
123-
# def theme
124-
# @theme ||= fetch_theme.call
125-
# end
126-
127-
# def site
128-
# @site ||= fetch_site.call
129-
# end
130124
end

0 commit comments

Comments
 (0)