Module | RGen::MetamodelBuilder::BuilderExtensions |
In: |
lib/rgen/metamodel_builder/builder_extensions.rb
|
This module provides methods which can be used to setup a metamodel element. The module is used to extend MetamodelBuilder::MMBase, i.e. add the module‘s methods as class methods.
MetamodelBuilder::MMBase should be used as a start for new metamodel elements. See MetamodelBuilder for an example.
Add an attribute which can hold a single value. ‘role’ specifies the name which is used to access the attribute. ‘target_class’ specifies the type of objects which can be held by this attribute. If no target class is given, String will be default.
This class method adds the following instance methods, where ‘role’ is to be replaced by the given role name:
class#role # getter class#role=(value) # setter
Add an unidirectional many association. ‘role’ specifies the name which is used to access the attribute. ‘target_class’ is optional and can be used to fix the type of objects which can be referenced by this association.
This class method adds the following instance methods, where ‘role’ is to be replaced by the given role name:
class#addRole(value, index=-1) class#removeRole(value) class#role # getter, returns an array
Note that the first letter of the role name is turned into an uppercase for the add and remove methods.
Add an attribute which can hold multiple values. ‘role’ specifies the name which is used to access the attribute. ‘target_class’ specifies the type of objects which can be held by this attribute. If no target class is given, String will be default.
This class method adds the following instance methods, where ‘role’ is to be replaced by the given role name:
class#addRole(value, index=-1) class#removeRole(value) class#role # getter, returns an array class#role= # setter, sets multiple values at once
Note that the first letter of the role name is turned into an uppercase for the add and remove methods.
Add a single unidirectional association. ‘role’ specifies the name which is used to access the association. ‘target_class’ specifies the type of objects which can be held by this association.
This class method adds the following instance methods, where ‘role’ is to be replaced by the given role name:
class#role # getter class#role=(value) # setter
Add a bidirectional many-to-many association between two classes. The class this method is called on is refered to as own_class in the following.
Instances of own_class can use ‘own_role’ to access many associated instances of type ‘target_class’. Instances of ‘target_class’ can use ‘target_role’ to access many associated instances of own_class.
This class method adds the following instance methods where ‘ownRole’ and ‘targetRole’ are to be replaced by the given role names:
own_class#addOwnRole(value, index=-1) own_class#removeOwnRole(value) own_class#ownRole target_class#addTargetRole target_class#removeTargetRole=(value) target_class#targetRole
Note that the first letter of the role name is turned into an uppercase for the add and remove methods.
When an element is added on either side, this element also receives the element is is added to as a new element.
This is the inverse of one_to_many provided for convenience.
Add a bidirectional one-to-many association between two classes. The class this method is called on is refered to as own_class in the following.
Instances of own_class can use ‘own_role’ to access many associated instances of type ‘target_class’. Instances of ‘target_class’ can use ‘target_role’ to access one associated instance of own_class.
This class method adds the following instance methods where ‘ownRole’ and ‘targetRole’ are to be replaced by the given role names:
own_class#addOwnRole(value, index=-1) own_class#removeOwnRole(value) own_class#ownRole target_class#targetRole target_class#targetRole=(value)
Note that the first letter of the role name is turned into an uppercase for the add and remove methods.
When an element is added/set on either side, this element also receives the element is is added to as a new element.
Add a bidirectional one-to-one association between two classes. The class this method is called on is refered to as own_class in the following.
Instances of own_class can use ‘own_role’ to access one associated instance of type ‘target_class’. Instances of ‘target_class’ can use ‘target_role’ to access one associated instance of own_class.
This class method adds the following instance methods where ‘ownRole’ and ‘targetRole’ are to be replaced by the given role names:
own_class#ownRole own_class#ownRole=(value) target_class#targetRole target_class#targetRole=(value)
When an element is set on either side, this element also receives the element is is added to as the new element.