Sha256: 5764fdd916e64c1916f736fef8aac093cf925090354f9f3f81ed76f7bfa17a47

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

module Seiun
  module XMLParsers
    class ResultXML < Base
      class << self
        def each(xml_str, &block)
          parse(xml_str, "result", block)
        end
      end

      def result_id
        return unless result.is_a?(String)
        result
      end

      [ :id, :success ].each do |name|
        define_method name do
          return unless result.is_a?(Hash)
          result[Seiun::Utils.camelize(name)]
        end
      end

      private

      def result
        if @attrs.size == 1 && @attrs.first.is_a?(String)
          @attrs.first
        else
          to_hash
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
seiun-0.0.2 lib/seiun/xml_parsers/result_xml.rb
seiun-0.0.1 lib/seiun/xml_parsers/result_xml.rb