class Cmpi::CMPIObjectPath

CMPIObjectPath

Attributes

typemap[RW]

Public Instance Methods

method_missing(name, *args) click to toggle source

Allow Ref.Property and Ref.Property=

# File ruby/cmpi.rb, line 420
    def method_missing name, *args
      s = name.to_s
      if s =~ /=$/
        v = args[0]
        n = s.chop
        # -> http://blog.sidu.in/2008/02/loading-classes-from-strings-in-ruby.html
        unless @typemap
          begin
            @typemap = Cmpi.const_get(self.classname).typemap
          rescue NameError
            raise RCErrInvalidClass.new(CMPI_RC_ERR_INVALID_CLASS, "Cmpi::#{self.classname}.typemap not defined")
          end
        end
        t = @typemap[n]
        raise RCErrNotFound.new(CMPI_RC_ERR_NOT_FOUND, "Property '#{n}' of Cmpi::#{self.classname}.typemap not defined") unless t
#        STDERR.printf "ObjectPath.%s = %s[%s]:%04x\n" % [n, v, v.class, t]
        self[n,v] = t
      else
#       STDERR.puts "CMPIObjectPath.#{name} -> #{self[s].inspect}"
        self[s]
      end
    end