Class: SDL::Base::Property
- Inherits:
-
Object
- Object
- SDL::Base::Property
- Defined in:
- lib/sdl/base/property.rb,
lib/sdl/util/documentation.rb,
lib/sdl/exporters/xml_mapping.rb
Overview
A property of a Fact or Type. It has a #name and an associated Type.
Instance Attribute Summary collapse
-
#holder ⇒ Object
The type, which currently holds this property.
-
#multi ⇒ Object
readonly
Is this Property multi-valued.
-
#name ⇒ Object
readonly
The Property name.
-
#parent ⇒ Object
readonly
The type, for which the property is defined.
-
#type ⇒ Object
readonly
The Property Type.
Instance Method Summary collapse
-
#documentation_key ⇒ Object
As properties are inherited, the documentation could either be defined by the current type, or any subtypes, which also define or inherit this key.
-
#initialize(name, type, parent, multi = false) ⇒ Property
constructor
Define a property by its name and type.
-
#multi? ⇒ Boolean
Is this Property multi-valued.
-
#single? ⇒ Boolean
Is this Property single-valued.
- #xsd_element_name ⇒ Object
Constructor Details
#initialize(name, type, parent, multi = false) ⇒ Property
Define a property by its name and type
30 31 32 |
# File 'lib/sdl/base/property.rb', line 30 def initialize(name, type, parent, multi = false) @name, @type, @parent, @multi = name.to_s, type, parent, multi end |
Instance Attribute Details
#holder ⇒ Object
The type, which currently holds this property
17 18 19 |
# File 'lib/sdl/base/property.rb', line 17 def holder @holder end |
#multi ⇒ Object (readonly)
Is this Property multi-valued
11 12 13 |
# File 'lib/sdl/base/property.rb', line 11 def multi @multi end |
#name ⇒ Object (readonly)
The Property name
5 6 7 |
# File 'lib/sdl/base/property.rb', line 5 def name @name end |
#parent ⇒ Object (readonly)
The type, for which the property is defined
14 15 16 |
# File 'lib/sdl/base/property.rb', line 14 def parent @parent end |
#type ⇒ Object (readonly)
The Property Type
8 9 10 |
# File 'lib/sdl/base/property.rb', line 8 def type @type end |
Instance Method Details
#documentation_key ⇒ Object
As properties are inherited, the documentation could either be defined by the current type, or any subtypes, which also define or inherit this key. This method finds the first defined key.
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/sdl/util/documentation.rb', line 85 def documentation_key # Search class and ancestors, if any defines a documentation key @holder.ancestors.each do |ancestor| break if ancestor.eql?(SDL::Base::Type) || ancestor.eql?(SDL::Types::SDLType) key = "sdl.property.#{SDL::Util::Documentation.walk_the_class_name(ancestor)}.#{@name}" return key if I18n.exists? key end # Return default key return "sdl.property.#{SDL::Util::Documentation.walk_the_class_name(@parent)}.#{@name}" end |
#multi? ⇒ Boolean
Is this Property multi-valued
25 26 27 |
# File 'lib/sdl/base/property.rb', line 25 def multi? @multi end |
#single? ⇒ Boolean
Is this Property single-valued
20 21 22 |
# File 'lib/sdl/base/property.rb', line 20 def single? !@multi end |
#xsd_element_name ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/sdl/exporters/xml_mapping.rb', line 4 def xsd_element_name if multi? @name.singularize else @name end end |