Module: Riagent::Conversion
- Defined in:
- lib/riagent/conversion.rb
Instance Method Summary collapse
-
#destroyed? ⇒ Boolean
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
Mark the document as saved/persisted Called by
save, and when instantiating query results (see ::Persistence). -
#persisted? ⇒ Boolean
Has this document been saved to RiakJson? 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?
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
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
36 37 38 |
# File 'lib/riagent/conversion.rb', line 36 def new_record? !persisted? end |
#persist! ⇒ Object
Mark the document as saved/persisted Called by save, and when instantiating query results (see ::Persistence)
42 43 44 |
# File 'lib/riagent/conversion.rb', line 42 def persist! @persisted = true end |
#persisted? ⇒ Boolean
Has this document been saved to RiakJson? Required by ActiveModel::Conversion API
49 50 51 |
# File 'lib/riagent/conversion.rb', line 49 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
56 57 58 |
# File 'lib/riagent/conversion.rb', line 56 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
62 63 64 |
# File 'lib/riagent/conversion.rb', line 62 def to_model self end |
#to_param ⇒ String?
Returns a string representing the object’s key suitable for use in URLs, or nil if persisted? is false. Required by ActiveModel::Conversion API
70 71 72 |
# File 'lib/riagent/conversion.rb', line 70 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
79 80 81 |
# File 'lib/riagent/conversion.rb', line 79 def to_partial_path "#{self.class.collection_name}/#{self.key}" end |