Basically the same question asked here, but then a Ruby solution.
I have a class, with static functions that fill the class:
class Message
  attributes :message, :origin
  def initialize(params)
   self.origin = initialize_called_by
   super
  end
  def self.failed_to_save
    Message.new(message: 'Failed to save that thing!')
  end
  def self.failed_to_delete
    Message.new(message: 'Failed to delete that thing!')
  end
end
Where I'd expect origin to contain the following:
Message.failed_to_save.origin # failed_to_save
Message.failed_to_delete.origin # failed_to_delete
 
    