Sha256: 1dc4d3aeaf8464cbaf705694e9991cbcc3910a35e929b00a0422ad2a0687aa4d

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

#
# cim/property.rb - class CIM::Property
#
# A pure-Ruby implementation of the CIM meta model.
#
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
#
# Licensed under the Ruby license
#
module CIM
  #
  # A Property defines a data member of a Class.
  #
  # For method members, see Method.
  #
  class Property < CIM::ClassFeature
    attr_reader :default
    #
    # Create a Property with type (Type) and name (String), optional QualifierSet and default value
    #
    # call-seq:
    #   Property.new(:boolean, "flag")
    #   Property.new(:boolean, "flag", qualifier_set)
    #   Property.new(:boolean, "flag", qualifier_set, true)
    #
    def initialize type, name, qualifier_set=nil, default=nil
      @default = default
      super type, name, qualifier_set
    end
    #
    # Makes a Property recognizable in the set of Class features.
    #
    def property?
      true
    end
    #
    # Check for qualifiers
    #
    #  # check for existance
    #  element.qualifier? -> true or false
    #
    #  # check value
    #  element.description -> String or nil
    #
    def method_missing name, *args
      if name.to_s[-1,1] == "?"
        @qualifiers && @qualifiers.include?(name.to_s[0...-1])
      else
        (@qualifiers[name].value || @qualifiers[name].declaration.default) rescue nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cim-1.4.2 lib/cim/property.rb
cim-1.4.1 lib/cim/property.rb