Class: Adaptation::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #process(xml_message) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
43 44 45 46 47 48 49 50 |
# File 'lib/adaptation/base.rb', line 43 def initialize Initializer.run @@logger = Logger.new("#{ADAPTOR_ROOT}/log/#{ADAPTOR_ENV}.log") ActiveRecord::Base.logger = @@logger end |
Class Method Details
.logger ⇒ Object
52 53 54 |
# File 'lib/adaptation/base.rb', line 52 def self.logger @@logger end |
Instance Method Details
#process(xml_message) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/adaptation/base.rb', line 56 def process() # dirty method to discover the message type # TODO: move to a module = [1..(.index(/(>| |\/)/) - 1)] adaptor = = nil = Adaptation::Message.get_class_object(.capitalize) = .nil? ? : .to_object() # TODO: the xml is returned as a String if a class to map it is not found; # in future versions Adaptation may build a valid Adaptation::Message even # without implementation for this type of message adaptor_class = Adaptation::Adaptor.get_class_object("#{.capitalize}Adaptor") adaptor = adaptor_class.nil? ? ApplicationAdaptor.new : adaptor_class.new rescue Adaptation::Adaptor.new unless .is_a?(String) # TODO: remove when feature explained in line 67 implemented unless .valid? @@logger.info "WARNING:Message doesn't validate!" return end end adaptor.process end |