Class: ActiveRecord::Remote::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/remote/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Response

Returns a new instance of Response.



9
10
11
12
# File 'lib/active_record/remote/response.rb', line 9

def initialize(options)
  @options = options
  handle_response(options[:raw_response])
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/active_record/remote/response.rb', line 5

def options
  @options
end

#parsed_responseObject Also known as: parsed

Returns the value of attribute parsed_response.



5
6
7
# File 'lib/active_record/remote/response.rb', line 5

def parsed_response
  @parsed_response
end

Instance Method Details

#handle_response(response) ⇒ Object



26
27
28
# File 'lib/active_record/remote/response.rb', line 26

def handle_response(response)
  # implement in subclass
end

#operationObject



14
15
16
# File 'lib/active_record/remote/response.rb', line 14

def operation
  options[:operation]
end

#record_instanceObject



18
19
20
# File 'lib/active_record/remote/response.rb', line 18

def record_instance
  options[:instance]
end

#response_messageObject



30
31
32
# File 'lib/active_record/remote/response.rb', line 30

def response_message
  # implement in subclass
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/active_record/remote/response.rb', line 22

def success?
  record_instance.errors.blank?
end

#valid?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/active_record/remote/response.rb', line 34

def valid?
  # implement in subclass
end