module Tripod::State
This module contains the behaviour for getting the various states through which a resource can transition.
Attributes
Public Instance Methods
Returns true if the Resource
has been succesfully destroyed, and false if it hasn't. This is determined by the variable @destroyed and NOT by checking the database.
@example Is the resource destroyed?
person.destroyed?
@return [ true, false ] True if destroyed, false if not.
# File lib/tripod/state.rb, line 42 def destroyed? @destroyed ||= false end
Returns true if the Resource
has not been persisted to the database, false if it has. This is determined by the variable @new_record and NOT if the object has an id.
@example Is the resource new?
person.new_record?
@return [ true, false ] True if new, false if not.
# File lib/tripod/state.rb, line 19 def new_record? @new_record ||= false end
Checks if the resource has been saved to the database. Returns false if the resource has been destroyed.
@example Is the resource persisted?
person.persisted?
@return [ true, false ] True if persisted, false if not.
# File lib/tripod/state.rb, line 30 def persisted? !new_record? && !destroyed? end