Sha256: 7b8718c63cca9109a290d8b0c7c40d3bdc1bc66ce48c32d3f8e9c064e593f63e
Contents?: true
Size: 1023 Bytes
Versions: 2
Compression:
Stored size: 1023 Bytes
Contents
module Restly::Base::Instance::Persistence def exists? return false unless id begin @response = connection.get(path, force: true) unless @response.status.to_i < 400 rescue OAuth2::Error => e @response = e.response end status = @response.status.to_i status < 400 && status >= 200 end def persisted? exists? && !changed? end def new_record? !exists? end def reload! return unless initialized? && loaded? raise Restly::Error::MissingId, "Cannot reload #{resource_name}, either it hasn't been created or it is missing an ID." unless exists? @loaded = true set_attributes_from_response connection.get(path_with_format, force: true) self end def load! return unless initialized? && loaded? raise Restly::Error::MissingId, "Cannot load #{resource_name}, either it hasn't been created or it is missing an ID." unless exists? @loaded = true set_attributes_from_response connection.get(path_with_format) self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restly-0.0.1.beta.5 | lib/restly/base/instance/persistence.rb |
restly-0.0.1.beta.4 | lib/restly/base/instance/persistence.rb |