Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Interacting with 3rd party services

Interacting with 3rd party services

Lightning talk at RuLu 2014

Jérémy Lecour

June 20, 2014

Transcript

13 slides
  1. Mapping to Ruby objects • JSON to Hash : easy

    • XML to Nokogiri : doable • SOAP to anything : attrocious
  2. require 'roxml' module Mapping class Base include ROXML xml_convention :capitalize

    end class Room < Base xml_reader :total_price, :from => '@TotalPrice', :as => Float xml_reader :nb_rooms, :from => '@NbRooms', :as => Integer def breakfast_included? %w(B D P A).include?(meals.to_s) end end class Hotel < Base xml_reader :native_id, :from => "@DistNum" xml_reader :name, :from => "@Name" xml_reader :rooms, :as => [Room] end class FB_MultirateRS < Base xml_reader :hotels, :as => [Hotel], :from => 'Hotels/Hotel' end end

More Decks by Jérémy Lecour

Other Decks in Technology