Class: Maglev::Sections::RenameCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



8
9
10
# File 'lib/commands/maglev/sections/rename_command.rb', line 8

def self.banner
  'bin/rails maglev:sections:rename OLD_TYPE NEW_TYPE'
end

Instance Method Details

#perform(old_type, new_type) ⇒ Object



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

def perform(old_type, new_type)
  require File.expand_path('config/environment', Rails.root)

  site = fetch_site
  theme = fetch_theme

  return if site.blank? || theme.blank?

  rename_sections(site, theme, old_type, new_type)

  say "Successfully renamed all '#{old_type}' sections to '#{new_type}' 🎉", :green
end