Class: Yesterday::Versioning
- Inherits:
-
Object
- Object
- Yesterday::Versioning
- Defined in:
- lib/yesterday/versioning.rb
Class Method Summary collapse
- .changeset_for(version_number, object) ⇒ Object
- .changesets_for(object) ⇒ Object
- .create_changeset_for(object) ⇒ Object
- .current_version_number_for(object) ⇒ Object
- .diff_for(from_version_number, to_version_number, object) ⇒ Object
- .object_attributes_for(version_number, object) ⇒ Object
- .versioned_object_for(version_number, object) ⇒ Object
Class Method Details
.changeset_for(version_number, object) ⇒ Object
28 29 30 |
# File 'lib/yesterday/versioning.rb', line 28 def changeset_for(version_number, object) Changeset.for_changed_object(object).version(version_number).first end |
.changesets_for(object) ⇒ Object
8 9 10 |
# File 'lib/yesterday/versioning.rb', line 8 def changesets_for(object) Changeset.for_changed_object(object) end |
.create_changeset_for(object) ⇒ Object
4 5 6 |
# File 'lib/yesterday/versioning.rb', line 4 def create_changeset_for(object) Changeset.create :changed_object => object end |
.current_version_number_for(object) ⇒ Object
12 13 14 |
# File 'lib/yesterday/versioning.rb', line 12 def current_version_number_for(object) changesets_for(object).last.try(:version_number) || 0 end |
.diff_for(from_version_number, to_version_number, object) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/yesterday/versioning.rb', line 20 def diff_for(from_version_number, to_version_number, object) from_attributes = object_attributes_for(from_version_number, object) to_attributes = object_attributes_for(to_version_number, object) diff = Differ.new(from_attributes, to_attributes).diff VersionedObjectCreator.new(diff).to_object end |
.object_attributes_for(version_number, object) ⇒ Object
32 33 34 |
# File 'lib/yesterday/versioning.rb', line 32 def object_attributes_for(version_number, object) changeset_for(version_number, object).object_attributes end |
.versioned_object_for(version_number, object) ⇒ Object
16 17 18 |
# File 'lib/yesterday/versioning.rb', line 16 def versioned_object_for(version_number, object) changeset_for(version_number, object).try(:object) end |