Module: CleanModel::Remote::InstanceMethods
- Defined in:
- lib/clean_model/remote.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/clean_model/remote.rb', line 36 def destroy return true if new_record? begin response = delete unless response.success? errors[:base] = response.content_type == 'application/json' ? response.body : "#{response.code} - Unexpected error" end rescue WebClient::Error => ex errors[:base] = ex. end errors.empty? end |
#save ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clean_model/remote.rb', line 20 def save return false unless valid? begin response = new_record? ? create : update if response.success? save_success(response) else save_fail(response) end rescue WebClient::Error => ex puts ex.inspect errors[:base] = ex. end errors.empty? end |