I have these 2 models:
class Slot
include DataMapper::Resource
belongs_to :license
property :id, Serial
property :slot_nr, Integer
property :exp, DateTime
property :user_count, Integer
end
class SlotInfo
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :visible, Boolean, :default => lambda { |r, p|
default_visible(r, p) }
property :category, String
def name
SlotInfo.get(slot_nr).name
end
def visible?
SlotInfo.get(slot_nr).visible?
end
end
Is there a way to "merge" the name and visible properties from
SlotInfo into Slot via association?
So that I could omit the name and visible? methods and get these
values transparently through a join query when fetching a Slot from
the db?
Something like:
property :visible, :through => :slot_info, :key => :slot_nr
It works with the current code, but I cannot fetch all visible slots
via the license association at the moment:
"license.slots.visible" would be nice to have.
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.