Class: Reactor::Plans::UpdateObj

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

Instance Method Summary collapse

Methods included from Prepared

#error, #separate_arguments

Constructor Details

#initialize(opts = {}) ⇒ UpdateObj

Returns a new instance of UpdateObj.



6
7
8
9
# File 'lib/reactor/plans/update_obj.rb', line 6

def initialize(opts = {})
  @key = opts[:obj_id] || opts[:path]
  @attrs = {}
end

Instance Method Details

#migrate!Object



20
21
22
23
24
25
26
27
# File 'lib/reactor/plans/update_obj.rb', line 20

def migrate!
  Reactor::Cm::Obj.get(@key)
  @attrs.each do |key, value|
    @obj.set(key, value)
  end
  @obj.save!
  @obj.release!
end

#prepare!Object



15
16
17
18
# File 'lib/reactor/plans/update_obj.rb', line 15

def prepare!
  error("object (key=#{@key}) not found") unless Reactor::Cm::Obj.exists?(@key)
  # TODO: attribute check
end

#set(key, value) ⇒ Object



11
12
13
# File 'lib/reactor/plans/update_obj.rb', line 11

def set(key, value)
  @attrs[key.to_sym] = value
end