Class: PagSeguro::Subscription::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/pagseguro/subscription/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, object) ⇒ Response

Returns a new instance of Response.



10
11
12
13
# File 'lib/pagseguro/subscription/response.rb', line 10

def initialize(response, object)
  @response = response
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Set the object that will recive errors or updates



8
9
10
# File 'lib/pagseguro/subscription/response.rb', line 8

def object
  @object
end

#responseObject (readonly)

The http response



5
6
7
# File 'lib/pagseguro/subscription/response.rb', line 5

def response
  @response
end

Instance Method Details

#serialize(kind = :normal) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pagseguro/subscription/response.rb', line 30

def success?
  response.success? && response.xml?
end