module Riagent::Conversion

Public Instance Methods

deleted?()
Alias for: destroyed?
destroyed?() click to toggle source

Has this document been deleted? Required by ActiveModel::Conversion API @return [Boolean]

# File lib/riagent/conversion.rb, line 29
def destroyed?
  @destroyed ||= false
end
Also aliased as: deleted?
new_record?() click to toggle source

Is this a new, unsaved document? Required by ActiveModel::Conversion API @return [Boolean]

# File lib/riagent/conversion.rb, line 37
def new_record?
  !persisted?
end
persist!() click to toggle source

Marks the document as saved/persisted Called by save, and when instantiating query results (see ::Persistence)

# File lib/riagent/conversion.rb, line 43
def persist!
  @persisted = true
end
persisted?() click to toggle source

Has this document been saved to Riak? Required by ActiveModel::Conversion API @return [Boolean]

# File lib/riagent/conversion.rb, line 50
def persisted?
  @persisted ||= false
end
to_key() click to toggle source

Returns an Enumerable of all key attributes if any is set, or nil if the document is not persisted Required by ActiveModel::Conversion API

# File lib/riagent/conversion.rb, line 57
def to_key
  self.new_record? ? nil : [self.key]
end
to_model() click to toggle source

Returns an instance of an ActiveModel object (ie, itself) Required by ActiveModel::Conversion API

# File lib/riagent/conversion.rb, line 63
def to_model
  self
end
to_param() click to toggle source

Returns a string representing the object’s key suitable for use in URLs, or nil if persisted? is false. Required by ActiveModel::Conversion API @return [String|nil]

# File lib/riagent/conversion.rb, line 71
def to_param
  self.key
end
to_partial_path() click to toggle source

Returns a string identifying the path associated with the object. ActionPack uses this to find a suitable partial to represent the object. Used in Rails helper methods such as link_to Required by ActiveModel::Conversion API @return [String]

# File lib/riagent/conversion.rb, line 80
def to_partial_path
  "#{self.class.collection_name}/#{self.key}"
end