Class: Reactor::Plans::RenameGroup

Inherits:
Object
  • Object
show all
Includes:
Prepared
Defined in:
lib/reactor/plans/rename_group.rb

Instance Method Summary collapse

Methods included from Prepared

#error, #separate_arguments

Constructor Details

#initialize(*args) ⇒ RenameGroup

Returns a new instance of RenameGroup.



6
7
8
9
10
11
# File 'lib/reactor/plans/rename_group.rb', line 6

def initialize(*args)
  (from, to), options = separate_arguments(*args)

  @from = from || options[:from]
  @to = to || options[:to]
end

Instance Method Details

#migrate!Object



20
21
22
23
# File 'lib/reactor/plans/rename_group.rb', line 20

def migrate!
  group = Reactor::Cm::Group.get(@from)
  group.rename!(@to)
end

#prepare!Object



13
14
15
16
17
18
# File 'lib/reactor/plans/rename_group.rb', line 13

def prepare!
  error("from is nil") if @from.nil?
  error("to is nil") if @to.nil?
  error("from does not exist") unless Reactor::Cm::Group.exists?(@from)
  error("to does exist") if Reactor::Cm::Group.exists?(@to)
end