Module: Daylight::Errors::ClassMethods
- Defined in:
- lib/daylight/errors.rb
Instance Method Summary collapse
-
#from_json(json) ⇒ Object
Parse payload that is in JSON -- Examples:.
-
#from_xml(xml) ⇒ Object
Parse payload that is in XML -- Examples:
this is a Problem .this is problem one this is problem one
Instance Method Details
#from_json(json) ⇒ Object
Parse payload that is in JSON
Examples:
is the problem' is problem one','this is problem two']
64 65 66 67 68 69 70 71 |
# File 'lib/daylight/errors.rb', line 64 def from_json(json) decoded = ActiveSupport::JSON.decode(json) || {} rescue {} if decoded.kind_of?(Hash) && decoded.has_key?('errors') Array.wrap(decoded['errors']) else [] end end |
#from_xml(xml) ⇒ Object
Parse payload that is in XML
Examples:
84 85 86 |
# File 'lib/daylight/errors.rb', line 84 def from_xml(xml) Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue [] end |