Example:
class Project
include DataMapper::Resource
has n, :tasks
end
class Task
include DataMapper::Resource
....
end
Say I have object "p" (Project::Class) and object
"association" (:tasks). How can I determine that "association" is of
class Task and instantiate a Task object using datamapper?
In ActiveRecord, I can do the following:
new_object = p.class.reflect_on_association(association).klass.new
What is the Datamapper equivalent?
On Aug 30, 5:04 pm, Jonathan Stott <[email protected]> wrote:
> On 30 August 2011 21:42, Paul <[email protected]> wrote:
>
> > Will datamapper support reflection anytime soon? I am talking about
> > the reflection feature that is supported in Active Record like
> > reflect_on_association, reflect_on_aggregation, etc. I am using some
> > scripts that require this feature so I don't know what to do without
> > it.
>
> > Thanks,
>
> > Paul
>
> What does "this feature" actually do? I'm not at all familiar with
> active_record. However, you can access all the relationship objects
> on the model via the ModelClass.relationships method, which seems to
> be what "reflect_on_association" does.
>
> Regards
> Jon
--
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.