Hi Tom,
resource.attributes.each { |name, value| … }
Is probably what you're looking for.
Cheers,
Chris
On 21/11/2011, at 12:12 PM, tomPorter wrote:
> Assume I have a model
>
> class Job
> include DataMapper::Resource
> property :qsid, Serial
> property :clientcode,String
> end
>
> I know I can iterate through Job.properties to find out what the
> instance variables are called.
>
> Lets say I have:
>
> job = Job.first
>
> is there a way I can iterate through the instance variables without
> knowing what they are called?
> (I'm trying to DRY out some HAML template code that is populating a
> table with Job instances. Currently if I change the model, I have to
> change the template code by hand.)
>
> I can pass the Job.properties into my template to populate the header
> row for my HAML table by iterating through them, but is there a way to
> iterate through the instance variables of a Job instance in a similar
> way?
>
> --
> 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.
>
--
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.