class Lumberjack::Formatter::IdFormatter
Format an object that has an id as a hash with keys for class and id. This formatter is useful as a default formatter for objects pulled from a data store. By default it will use :id as the id attribute.
Public Class Methods
new(id_attribute = :id)
click to toggle source
# File lib/lumberjack/formatter/id_formatter.rb, line 9 def initialize(id_attribute = :id) @id_attribute = id_attribute end
Public Instance Methods
call(obj)
click to toggle source
# File lib/lumberjack/formatter/id_formatter.rb, line 13 def call(obj) if obj.respond_to?(@id_attribute) id = obj.send(@id_attribute) {"class" => obj.class.name, "id" => id} else obj.to_s end end