Class: CIM::Property

Inherits:
ClassFeature show all
Defined in:
lib/cim/property.rb

Overview

A Property defines a data member of a Class.

For method members, see Method.

Direct Known Subclasses

Reference

Instance Attribute Summary collapse

Attributes inherited from ClassFeature

#type

Attributes inherited from NamedElement

#name, #qualifiers

Instance Method Summary collapse

Methods inherited from ClassFeature

#method?, #reference?

Methods inherited from NamedElement

#<<, #include?, #to_s

Constructor Details

#initialize(type, name, qualifier_set = nil, default = nil) ⇒ Property

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)


26
27
28
29
# File 'lib/cim/property.rb', line 26

def initialize type, name, qualifier_set=nil, default=nil
  @default = default
  super type, name, qualifier_set
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Check for qualifiers

# check for existance
element.qualifier? -> true or false

# check value
element.description -> String or nil


45
46
47
48
49
50
51
# File 'lib/cim/property.rb', line 45

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

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



17
18
19
# File 'lib/cim/property.rb', line 17

def default
  @default
end

Instance Method Details

#property?Boolean

Makes a Property recognizable in the set of Class features.

Returns:

  • (Boolean)


33
34
35
# File 'lib/cim/property.rb', line 33

def property?
  true
end