Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to another model builder #26

Open
nicoh opened this issue Jul 9, 2015 · 2 comments
Open

Reference to another model builder #26

nicoh opened this issue Jul 9, 2015 · 2 comments

Comments

@nicoh
Copy link

nicoh commented Jul 9, 2015

The following is more a question than an issue. I have the following situation: I have two meta-models, let's say "car.rb" and "wheel.rb". Now I would like to make within the "Car" ModelBuilder a reference to a Wheel created by the Wheel model builder. Is there any standard way? Note, in the Car metamodel I manually inserted the following:

require_relative 'wheel'
...
CarMetaModel::Car.contains_many_uni 'wheels', WheelMetaModel::Wheel
@mthiede
Copy link
Owner

mthiede commented Jul 9, 2015

You can pass only one package into the model builder (either the module corresponding to the package or an EPackage object).

The first thing I would try is to use only one single metamodel. A model normally is an instance of one metamodel not of two metamodels. So I would put your two partial metamodels into two subpackages of one overall metamodel.

Note that you can use Ruby's open classes/modules feature to still split the metamodels into two files if you need that: Create the toplevel package in one file and add one subpackage, then open it in the other file and add the other subpackage.

If that's not possible you could try a trick: Create a new EPackage object and add the EPackage objects of your two metamodels as child packages. Then pass the toplevel EPackage object to the metamodel builder.

@nicoh
Copy link
Author

nicoh commented Jul 10, 2015

Thanks for the help. Option a) seems to work partially. The problem which remains (I guess due to my lack of Ruby knowledge) is how to reference the "Continental" wheel in the code below.

require 'rgen/model_builder'
require_relative '../generated/test'

RGen::ModelBuilder.build(TestMetaModel) do
    RGen::ModelBuilder.build(TestMetaModel::WheelPackage) do
        Wheel "Continental"
    end

    RGen::ModelBuilder.build(TestMetaModel::CarPackage) do
        Car "Audi", :wheel => ["Continental"]
    end
end

I guess I need to convert the wheel block in a proc, or something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants