Datamapper not loading lazy property on first call to accessor method.

21 views
Skip to first unread message

jbrennan

unread,
Jul 18, 2012, 12:41:30 PM7/18/12
to datam...@googlegroups.com
I've got a Text property and I understand those are considered lazy by default. That's OK. But I'm having an issue where it does not appear to be loading the property even though I'm accessing it (and I've checked elsewhere the property is non-nil). Code looks like the following:

puts "Checking article: " + article.inspect # reveals article.body=<not loaded>
return :error if !article.body # returns here instead of loading body!!

Am I doing something wrong? I would expect my second line to load the body property and then return accordingly.

Thanks,
Jason.

jbrennan

unread,
Jul 18, 2012, 12:44:39 PM7/18/12
to datam...@googlegroups.com
Scratch that. I had an extra ! somewhere it didn't belong. How terribly embarrassing.

Abe Voelker

unread,
Jul 18, 2012, 12:51:27 PM7/18/12
to datam...@googlegroups.com
You could also forgo the ! by writing it with unless:

return :error unless article.body
Reply all
Reply to author
Forward
0 new messages