Permalink
Browse files

Merge branch 'master' of github.com:kkaempf/cim

  • Loading branch information...
kkaempf committed Jun 27, 2012
2 parents 8cced67 + 81d76ba commit d44a0be68c13d9c61634fc5cb1716115e5a25700
Showing with 38 additions and 15 deletions.
  1. +1 −1 lib/cim.rb
  2. +0 −12 lib/cim/class_feature.rb
  3. +16 −0 lib/cim/method.rb
  4. +16 −0 lib/cim/property.rb
  5. +5 −2 test/test_property.rb
View
@@ -41,7 +41,7 @@
#
module CIM
- VERSION = '1.3'
+ VERSION = '1.4'
require 'cim/type'
require 'cim/variant'
require 'cim/qualifier_flavors'
View
@@ -19,18 +19,6 @@ module CIM
class ClassFeature < NamedElement
attr_reader :type
#
- # if has key qualifier
- #
- def key?
- @qualifiers && @qualifiers.include?(:key,:boolean)
- end
- #
- # if static (class-level) feature
- #
- def static?
- false
- end
- #
# if Property
#
def property?
View
@@ -45,5 +45,21 @@ def to_s
p = parameters.join(", ")
"#{super}(#{p})"
end
+ #
+ # Check for qualifiers
+ #
+ # # check for existance
+ # method.qualifier? -> true or false
+ #
+ # # check value
+ # method.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.value) rescue nil
+ end
+ end
end
end
View
@@ -33,6 +33,22 @@ def initialize type, name, qualifier_set=nil, default=nil
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.value) rescue nil
+ end
+ end
end
end
View
@@ -5,11 +5,14 @@
class PropertyTest < Test::Unit::TestCase
def test_init
- p = CIM::Property.new :string, "String", CIM::QualifierDeclaration.new(:key, :boolean), CIM::QualifierDeclaration.new(:description, :string, "This is a string", :class)
+ p = CIM::Property.new :string, "String", [CIM::QualifierDeclaration.new(:key, :boolean), CIM::QualifierDeclaration.new(:description, :string, "This is a string", :class)], "Default property value"
assert p
assert p.is_a? CIM::Property
assert_equal "String", p.name
-# assert p.key?
+ assert_kind_of String, p.default
+ assert p.key?
+ assert p.description
+ assert_kind_of String, p.description
end
def test_name
p = CIM::Property.new :uint32, "foo"

0 comments on commit d44a0be

Please sign in to comment.