On Aug 31, 3:56 pm, [email protected] wrote:
> I could be wrong again. But a simple solution that I would use for this issue
> would be:
>
> def the_same(var1, var2)
>   if var1 == var2
> end
>
> then on any of your calls you'd just have to put:
> if !the_same(session[:my_id], params['id'])
>   #if not the same
> else
>   #code if the same
> end

That would certainly work, the trouble would be the massive, obscure
crosscut. Which got me to thinking about embedding your idea in the
getter for the association, which then led to me wonder... well what
if...

def Post
  belongs_to :author, model: 'Person', required: false

  def author
    Person.get(attribute_get(:author_id))
  end
end

And, that actually prevents additional selects, presumably Model.get
is grabbing the instance the from the IdentityMap while the original
belongs_to method is hard-wired to hit the DB?

-- 
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.

Reply via email to