Module: Riagent::Conversion
- Defined in:
- lib/riagent/conversion.rb
Instance Method Summary collapse
-
#destroyed? ⇒ Boolean
(also: #deleted?)
Has this document been deleted? Required by ActiveModel::Conversion API.
-
#new_record? ⇒ Boolean
Is this a new, unsaved document? Required by ActiveModel::Conversion API.
-
#persist! ⇒ Object
Marks the document as saved/persisted Called by
save, and when instantiating query results (see ::Persistence). -
#persisted? ⇒ Boolean
Has this document been saved to Riak? Required by ActiveModel::Conversion API.
-
#to_key ⇒ Object
Returns an Enumerable of all key attributes if any is set, or
nilif the document is not persisted Required by ActiveModel::Conversion API. -
#to_model ⇒ Object
Returns an instance of an ActiveModel object (ie, itself) Required by ActiveModel::Conversion API.
-
#to_param ⇒ String|nil
Returns a
stringrepresenting the object’s key suitable for use in URLs, ornilifpersisted?isfalse. -
#to_partial_path ⇒ String
Returns a
stringidentifying the path associated with the object.
Instance Method Details
#destroyed? ⇒ Boolean Also known as: deleted?
Has this document been deleted? Required by ActiveModel::Conversion API
29 30 31 |
# File 'lib/riagent/conversion.rb', line 29 def destroyed? @destroyed ||= false end |
#new_record? ⇒ Boolean
Is this a new, unsaved document? Required by ActiveModel::Conversion API
37 38 39 |
# File 'lib/riagent/conversion.rb', line 37 def new_record? !persisted? end |
#persist! ⇒ Object
Marks the document as saved/persisted Called by save, and when instantiating query results (see ::Persistence)
43 44 45 |
# File 'lib/riagent/conversion.rb', line 43 def persist! @persisted = true end |
#persisted? ⇒ Boolean
Has this document been saved to Riak? Required by ActiveModel::Conversion API
50 51 52 |
# File 'lib/riagent/conversion.rb', line 50 def persisted? @persisted ||= false end |
#to_key ⇒ Object
Returns an Enumerable of all key attributes if any is set, or nil if the document is not persisted Required by ActiveModel::Conversion API
57 58 59 |
# File 'lib/riagent/conversion.rb', line 57 def to_key self.new_record? ? nil : [self.key] end |
#to_model ⇒ Object
Returns an instance of an ActiveModel object (ie, itself) Required by ActiveModel::Conversion API
63 64 65 |
# File 'lib/riagent/conversion.rb', line 63 def to_model self end |
#to_param ⇒ String|nil
Returns a string representing the object’s key suitable for use in URLs, or nil if persisted? is false. Required by ActiveModel::Conversion API
71 72 73 |
# File 'lib/riagent/conversion.rb', line 71 def to_param self.key end |
#to_partial_path ⇒ String
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
80 81 82 |
# File 'lib/riagent/conversion.rb', line 80 def to_partial_path "#{self.class.collection_name}/#{self.key}" end |