Class: Maglev::ChangeSiteLocalesCommand

Inherits:
Rails::Command::Base
  • Object
show all
Defined in:
lib/commands/maglev/change_site_locales_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



9
10
11
# File 'lib/commands/maglev/change_site_locales_command.rb', line 9

def self.banner(_command = nil, *)
  'bin/rails maglev:change_site_locales [label:prefix label2:prefix2 ...]'
end

Instance Method Details

#perform(*locale_args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/commands/maglev/change_site_locales_command.rb', line 13

def perform(*locale_args)
  require File.expand_path('config/environment', Rails.root)

  site = fetch_site
  return if site.blank?

  locales = build_locales(locale_args)
  return if locales.empty?

  update_site_locales(site, locales)
end