Module: ActiveRemote::Serialization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/active_remote/serialization.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_errors(errors) ⇒ Object
Add the given errors to our internal errors list.
-
#add_errors_from_response(response = nil) ⇒ Object
Examine the given response and add any errors to our internal errors list.
-
#serialize_records(records = nil) ⇒ Object
DEPRECATED – Use the class-level :serialize_errors instead.
Instance Method Details
#add_errors(errors) ⇒ Object
Add the given errors to our internal errors list
Examples
response = remote_call(:action_that_returns_errors, { :stuff => 'foo' })
add_errors(response.errors)
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_remote/serialization.rb', line 37 def add_errors(errors) errors.each do |error| if error.respond_to?(:message) self.errors.add(error.field, error.) elsif error.respond_to?(:messages) error..each do || self.errors.add(error.field, ) end end end end |
#add_errors_from_response(response = nil) ⇒ Object
Examine the given response and add any errors to our internal errors list.
Examples
response = remote_call(:action_that_returns_errors, { :stuff => 'foo' })
add_errors_from_response(response)
58 59 60 61 62 63 64 65 |
# File 'lib/active_remote/serialization.rb', line 58 def add_errors_from_response(response = nil) unless response warn 'DEPRECATED calling Model#add_errors_from_response without args is deprecated and will be removed in Active Remote 3.0.' response = last_response end add_errors(response.errors) if response.respond_to?(:errors) end |
#serialize_records(records = nil) ⇒ Object
DEPRECATED – Use the class-level :serialize_errors instead
69 70 71 72 73 74 75 76 |
# File 'lib/active_remote/serialization.rb', line 69 def serialize_records(records = nil) warn 'DEPRECATED Calling Model#serialize_records is deprecated and will be removed in Active Remote 3.0. Use Model.serialize_records instead' records ||= last_response.records if last_response.respond_to?(:records) return if records.nil? self.class.serialize_records(records) end |