class SDL::Base::Property

A property of a Fact or Type. It has a name and an associated Type.

Attributes

holder[RW]

The type, which currently holds this property @!attribute [r] holder @return [Class]

multi[R]

Is this Property multi-valued @!attribute [r] multi @return [Boolean]

name[R]

The Property name @!attribute [r] name @return [String]

parent[R]

The type, for which the property is defined @!attribute [r] parent @return [Class]

type[R]

The Property Type @!attribute [r] type @return [Class]

Public Class Methods

new(name, type, parent, multi = false) click to toggle source

Define a property by its name and type

# File lib/sdl/base/property.rb, line 60
def initialize(name, type, parent, multi = false)
  @name, @type, @parent, @multi = name.to_s, type, parent, multi
end

Public Instance Methods

documentation_key() click to toggle source

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.

# 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|
    next if (ancestor <=> SDL::Base::Type) == nil

    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
inherited?() click to toggle source

Was this property inherited from one of its parents? @return [Boolean]

# File lib/sdl/base/property.rb, line 51
def inherited?
  ! parent.eql? holder
end
multi?() click to toggle source

Is this Property multi-valued @return [Boolean]

# File lib/sdl/base/property.rb, line 44
def multi?
  @multi
end
simple_type?() click to toggle source
# File lib/sdl/base/property.rb, line 55
def simple_type?
  type <= SDL::Types::SDLSimpleType
end
single?() click to toggle source

Is this Property single-valued @return [Boolean]

# File lib/sdl/base/property.rb, line 37
def single?
  !@multi
end
to_s() click to toggle source
# File lib/sdl/base/property.rb, line 64
def to_s
  "#{@parent.original_name}.#{@name.to_s}"
end
xsd_element_name() click to toggle source
# File lib/sdl/exporters/xml_mapping.rb, line 4
def xsd_element_name
  if multi?
    @name.singularize
  else
    @name
  end
end