Method: Logging::Layouts::CouchDB.create_format_method

Defined in:
lib/logging/couch_db_layout.rb

.create_format_method(layout) ⇒ Object

call-seq:

CouchDB.create_format_method( layout )

This method will create the format method in the given CouchDB layout based on the configured items for the layout instance.



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/logging/couch_db_layout.rb', line 72

def self.create_format_method( layout )
  code = "undef :format if method_defined? :format\n"
  code << "def format( event )\n{"

  code << layout.items.map {|name|
    "#{name.to_sym.inspect} => #{CouchDB::DIRECTIVE_TABLE[name]}"
  }.join(',')
  code << "\n}\nend"
  
  (class << layout; self end).class_eval(code, __FILE__, __LINE__)
end