Sha256: f7f02c7c5e6bd0835fcb052ce98bc5bbc76f1cbf09b2c08c5c6653db68209661

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

require 'fiona7/builder/obj_builder'
#require 'fiona7/write_obj'

module Fiona7
  module Builder
    class ObjUpdater < ObjBuilder
      protected
      def update?
        true
      end

      def validate
        return true
      end

      def prepare_object
        obj_id       = @values.delete(:_id)
        @obj         = WriteObj.find(obj_id)
        @path        = @values.delete(:_path)
        @widget_pool = @values.delete(:_widget_pool)
        @permalink   = @values.key?(:_permalink) ? (@values.delete(:_permalink) || "") : nil

        # revert command sends this info. we cannot do anything useful with it.
        @values.delete(:_last_changed)

        @name, parent_path        = name_and_parent_path_from_path(@path) if (@path)
        old_name, old_parent_path = name_and_parent_path_from_path(@obj.path)

        if obj_class = @values.delete(:_obj_class)
          @obj_class      = obj_class
          @real_obj_class = Fiona7::ObjClassNameMangler.new(@obj_class).mangle
        else
          @real_obj_class = @obj.obj_class
          @obj_class      = Fiona7::ObjClassNameDemangler.new(@real_obj_class).demangle
        end

        ensure_obj_class_exists

        # NOTE: name is an object attribute and not content attribute
        # changing content attributes requires permissionWrite
        # but changing the name attribute requires permissionRoot
        #
        # setting the name without changing the value counts
        # as changing the name attribute for the CM
        @obj.name = @name if !@name.blank? && @name != @obj.name

        # this is a obj move operation
        if parent_path && old_parent_path != parent_path
          # we first have to make sure that the new parent exists
          # FIXME: moving the object and changing the obj class
          # will not move the object
          @obj.send(:set_parent, ContainerChainBuilder.new(parent_path).call )
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/builder/obj_updater.rb