Blueprints and inheritance

25 views
Skip to first unread message

Mike Gehard

unread,
Oct 13, 2009, 7:40:19 PM10/13/09
to Machinist Users
Hello all,

Thanks Pete for creating Machinist.

I have a question about using Machinist to create objects in an
inheritance hierarchy. Say I have a base class Person with two sub
classes, Employee and Manager.

How can I go about telling the Employee blueprint and it should
inherit from the Person blueprint and just add in some fields?

Thanks,
Mike

Pete Yandell

unread,
Oct 13, 2009, 8:17:22 PM10/13/09
to Machinist Users


On Oct 14, 10:40 am, Mike Gehard <m...@samyamatech.com> wrote:

> How can I go about telling the Employee blueprint and it should
> inherit from the Person blueprint and just add in some fields?

Machinist should do this for you automatically, as of a couple of
versions ago. It walks its way up the inheritance chain running
blueprints.

- Pete

Mike Gehard

unread,
Oct 13, 2009, 8:22:54 PM10/13/09
to Machinist Users
Thanks for the quick response Pete. I just want to make sure I
understand...

So I can create a User.blueprint() and fill in the properties specific
to the User class. I can then create an Employee.blueprint and fill
in the ones that the Employee adds.

Then when I call Employee.make(), Machinist will know that it's gonna
run the User.blueprint first and then the Employee.blueprint.

Thanks again...

Pete Yandell

unread,
Oct 13, 2009, 8:30:22 PM10/13/09
to Machinist Users


On Oct 14, 11:22 am, Mike Gehard <m...@samyamatech.com> wrote:
> So I can create a User.blueprint() and fill in the properties specific
> to the User class.  I can then create an Employee.blueprint and fill
> in the ones that the Employee adds.

Yep.

> Then when I call Employee.make(), Machinist will know that it's gonna
> run the User.blueprint first and then the Employee.blueprint.

Effectively, yes.

Internally, it's actually the other way around: the Employee blueprint
gets run first, then the User blueprint. The User blueprint will only
fill in attributes that weren't set by the Employee blueprint.

- Pete
Reply all
Reply to author
Forward
0 new messages