Sha256: dd5a47599c4877356c0280298905ecff8ccfcfb9cb2188f367c1918ec8200571

Contents?: true

Size: 678 Bytes

Versions: 7

Compression:

Stored size: 678 Bytes

Contents

module ActiveResource
   
  module Validations
    # Validate a resource and save (POST) it to the remote web service.
    def save_with_validation
      save_without_validation
      true
    rescue ResourceInvalid => error
      case error.response['Content-Type']
      when /xml/ #PATCH
        errors.from_xml(error.response.body)
      when /json/ #PATCH
        errors.from_json(error.response.body)
      end
      false
    end   
  end

  class Errors

    # Patched cause we dont need no attribute name magic .. and its just simpler
    def from_array(messages)
      clear
      messages.each do |msg|
        add msg[0], msg[1]
      end
    end
  end #Errors

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sk-api-1.0.6 lib/activeresource_patches/validations.rb
sk-api-1.0.5 lib/activeresource_patches/validations.rb
sk-api-1.0.4 lib/activeresource_patches/validations.rb
sk-api-1.0.3 lib/activeresource_patches/validations.rb
sk-api-1.0.2 lib/activeresource_patches/validations.rb
sk-api-1.0.1 lib/activeresource_patches/validations.rb
sk-api-1.0.0 lib/activeresource_patches/validations.rb