Module: ActiveResourceFixes

Extended by:
ActiveSupport::Concern
Defined in:
lib/remotable/active_resource_fixes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(method) ⇒ Object

! ActiveModel::AttributeMethods assumes that :attribute is the target for attribute lookup. ActiveResource doesn’t define that method.



11
12
13
# File 'lib/remotable/active_resource_fixes.rb', line 11

def attribute(method)
  attributes[method]
end

#destroy_with_validationObject

ActiveResource::Validations overrides ActiveResource::Base#save to rescue from ActiveResource::ResourceInvalid and record the resource’s errors. Do the same for ‘destroy`.



24
25
26
27
28
29
30
31
32
33
# File 'lib/remotable/active_resource_fixes.rb', line 24

def destroy_with_validation
  destroy_without_validation
rescue ActiveResource::ResourceInvalid => error
  # cache the remote errors because every call to <tt>valid?</tt> clears
  # all errors. We must keep a copy to add these back after local
  # validations.
  @remote_errors = error
  load_remote_errors(@remote_errors, true)
  false
end