Class: Services::MdsWsResponseHandler

Inherits:
Object
  • Object
show all
Includes:
LibXML::XML::SaxParser::Callbacks
Defined in:
app/models/services/mds_ws_response_handler.rb

Constant Summary collapse

COMPOSITE_FILE_RESPONSE =
'composite_file_response'
RESPONSE_NAME =
'Response'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



11
12
13
# File 'app/models/services/mds_ws_response_handler.rb', line 11

def response
  @response
end

Instance Method Details

#on_characters(text) ⇒ Object



22
23
24
25
26
27
# File 'app/models/services/mds_ws_response_handler.rb', line 22

def on_characters(text)
  return unless @response.respond_to?(@current_reader)

  current_value = @response.send(@current_reader)
  @response.send(@current_writer, current_value ? current_value + text.strip : text.strip)
end

#on_start_element(element_name, attributes) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/models/services/mds_ws_response_handler.rb', line 13

def on_start_element(element_name, attributes)
  @current_reader = element_name.to_sym
  @current_writer = "#{element_name}=".to_sym

  if element_name == COMPOSITE_FILE_RESPONSE
    @response = MdsWsResponse.new
  end
end