Blueprint inheritance and named blueprints

60 views
Skip to first unread message

Mike Gehard

unread,
Nov 5, 2009, 9:26:34 AM11/5/09
to Machinist Users
Hello Pete,

I have the following blueprints:
Location.blueprint() do
locality {Sham.location_city}
region {Sham.location_state}
country {"USA"}
user = User.make()
creator {user}
updater {user}
end

CarLocation.blueprint() do
street {Sham.location_street}
postal_code {Sham.location_postal_code}
end

Location.blueprint(:santa_barbara_ca) do
locality {"Santa Barbara"}
region {"CA"}
country {"USA"}
end

CarLocation.blueprint(:santa_barbara_ca) :as=> do
street {"233 W Micheltorena St"}
postal_code {"93101"}
end

When I call CarLocation.make(:santa_barbara_ca) I get a location back
with the street field = 233 W Micheltorena St and the postal_code
field = 93101 but the other fields (locality, region and country)
don't come back as Santa Barbara, CA and USA. These last three fields
come back with random values that look like they are being generated
by the Location.make() call.

Any thoughts?

Mike Gehard

unread,
Nov 5, 2009, 9:42:28 AM11/5/09
to Machinist Users
Please disregard the ":as=>" in the last blueprint...that is no longer
there and I'm still getting the behavior described above.

Pete Yandell

unread,
Nov 5, 2009, 5:48:27 PM11/5/09
to machini...@googlegroups.com
I assume CarLocation is a subclass of Location?

Machinist doesn't look for named blueprints when it climbs the
inheritance tree. When you call a named blueprint, it looks for:

- named blueprint for that class
- master blueprint for that class
- master blueprint of parent class
- master blueprint of grandparent class
etc.

You'll have to copy the attributes from the Location named blueprint
to the CarLocation named blueprint.


As an aside, you can make your Location blueprint a bit nicer:

creator { User.make }
updater { creator }

That'll prevent a user being created unnecessarily if you set the
creator in the argument to make.

- Pete

Mike Gehard

unread,
Nov 5, 2009, 5:57:33 PM11/5/09
to Machinist Users
Thanks Pete!
Reply all
Reply to author
Forward
0 new messages