Module: DataMapper::Is::Versioned::InstanceMethods
- Defined in:
- lib/dm-is-versioned/is/versioned.rb
Overview
ClassMethods
Instance Method Summary collapse
-
#pending_version_attributes ⇒ Hash
Returns a hash of original values to be stored in the versions table when a new version is created.
-
#versions ⇒ Collection
Returns a collection of other versions of this resource.
Instance Method Details
#pending_version_attributes ⇒ Hash
Returns a hash of original values to be stored in the versions table when a new version is created. It is cleared after a version model is created.
–
108 109 110 |
# File 'lib/dm-is-versioned/is/versioned.rb', line 108 def pending_version_attributes @pending_version_attributes ||= {} end |
#versions ⇒ Collection
Returns a collection of other versions of this resource. The versions are related on the models keys, and ordered by the version field.
–
119 120 121 122 123 124 |
# File 'lib/dm-is-versioned/is/versioned.rb', line 119 def versions version_model = model.const_get(:Version) query = Hash[ model.key.zip(key).map { |p, v| [ p.name, v ] } ] query.merge!(:order => version_model.key.map { |k| k.name.desc }) version_model.all(query) end |