Sha256: 36628d0576f05b98c6997c2f92ceae3d30641e6311a7bd8876f4c329e8b9b4ec

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

module Reactor
  module Plans
    class UpdateObj
      include Prepared

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
infopark_reactor_migrations-1.6.1 lib/reactor/plans/update_obj.rb
infopark_reactor_migrations-1.5.2 lib/reactor/plans/update_obj.rb
infopark_reactor_migrations-1.5.1 lib/reactor/plans/update_obj.rb