Class: Savon::LogMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/log_message.rb

Instance Method Summary collapse

Constructor Details

#initialize(message, filters = [], pretty_print = false) ⇒ LogMessage

Returns a new instance of LogMessage.



6
7
8
9
10
# File 'lib/savon/log_message.rb', line 6

def initialize(message, filters = [], pretty_print = false)
  @message      = message
  @filters      = filters
  @pretty_print = pretty_print
end

Instance Method Details

#to_sObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/savon/log_message.rb', line 12

def to_s
  message_is_xml = @message =~ /^</
  has_filters    = @filters.any?
  pretty_print   = @pretty_print

  return @message unless message_is_xml
  return @message unless has_filters || pretty_print

  document = Nokogiri.XML(@message)
  document = apply_filter(document) if has_filters
  document.to_xml(nokogiri_options)
end