class PagSeguro::Subscription::Response
Attributes
object[R]
Set the object that will recive errors or updates
response[R]
The http response
Public Class Methods
new(response, object)
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 10 def initialize(response, object) @response = response @object = object end
Public Instance Methods
serialize(kind = :normal)
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 15 def serialize(kind = :normal) if success? case kind when :normal object.update_attributes(serialized_data) when :search object.update_attributes(serialized_data_from_search) end else object.errors.add response end object end
success?()
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 30 def success? response.success? && response.xml? end
Private Instance Methods
serialized_data()
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 40 def serialized_data ResponseSerializer.new(xml).serialize end
serialized_data_from_search()
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 44 def serialized_data_from_search ResponseSerializer.new(xml).serialize_from_search end
xml()
click to toggle source
# File lib/pagseguro/subscription/response.rb, line 36 def xml Nokogiri::XML(response.body) end