Do AR callbacks know why they were called?

Hi all -

I was thinking today (dangerous) and got to wondering if AR callbacks
know why there were called. That is, do they know what triggered them.

Say I have…

class Foo << AR::Base
before_destroy :bar

before_create  :bar

def bar
  # Can I determine if I am creating or destroying here?
end

end

Let’s assume for a moment that new_record? isn’t available as I know
that would catch the before_create one, but wouldn’t work for
before_save/after_save/etc…

I didn’t see anything in perusing the docs/source, but might have
missed it…

Anyone know?

-philip

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs