Sha256: 1fcd1cdf12234062df083013795621c923843bf2d65058d04214eec5e8516868

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

require 'happymapper'
module Dineromail
  class Notification
    include HappyMapper
    
    tag 'operacion'
    element :transaction_id, Integer, :tag => 'id'
    element :type, String, :tag => 'tipo'
    
    def initialize(options = {})
      @options = options.symbolize_keys
    end
    
    def status_report
      unless @status_report
        @status_report = StatusReport.get_report_for(transaction_id,@options)
      end
      @status_report
    end
    
    def valid_report?
      status_report.valid_report?
    end
    
    def method_missing(symbol, *args)
      unless status_report.operations.empty?
        status_report.operations.first.send(symbol, *args)
      end
    end
    
    def self.parse(xml)
      #Convert tags to lowercase
      xml = xml.gsub(/<(.*?)[> ]/){|tag| tag.downcase}
      super(xml)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dineromail-0.1.4 lib/dineromail/notification.rb
dineromail-0.1.3 lib/dineromail/notification.rb