class Opera::MobileStore::PaymentInfo

Public Class Methods

build_from_nokogiri_node(node) click to toggle source
# File lib/opera/mobile_store/payment_info.rb, line 16
def self.build_from_nokogiri_node(node)
  if node.present?
    type = node.xpath("string(@type)").strip.downcase

    case type
    when "check"  then Check.build_from_nokogiri_node node
    when "wired"  then Wired.build_from_nokogiri_node node
    when "paypal" then PayPal.build_from_nokogiri_node node
    when "none"   then nil
    else raise "WTF?"
    end
  end
end
deserialize(serializable_hash) click to toggle source
# File lib/opera/mobile_store/payment_info.rb, line 30
def self.deserialize(serializable_hash)
  attributes_hash = serializable_hash.inject({}) do |hsh, keyval|
    field_name, field_value = keyval

    case field_name
    when 'payment_info'
      field_value = PaymentInfo.deserialize field_value
    end

    hsh[field_name] = field_value
    hsh
  end

  self.new attributes_hash
end

Public Instance Methods

type() click to toggle source
# File lib/opera/mobile_store/payment_info.rb, line 11
def type
  ref_type = self.class.name.demodulize.downcase
  ref_type == 'pay_pal' ? 'paypal' : ref_type
end