Class: VersionRecord::Sorting::Simple
- Inherits:
-
Object
- Object
- VersionRecord::Sorting::Simple
- Defined in:
- lib/version_record/sorting/simple.rb
Overview
Handles sorting a collection of AR objects.
This implementation uses in-memory sorting.
Instance Method Summary collapse
- #by_version(direction = :asc) ⇒ Object
-
#initialize(klass, version_column) ⇒ Simple
constructor
A new instance of Simple.
Constructor Details
#initialize(klass, version_column) ⇒ Simple
Returns a new instance of Simple.
9 10 11 12 |
# File 'lib/version_record/sorting/simple.rb', line 9 def initialize(klass, version_column) @klass = klass @version_column = version_column end |
Instance Method Details
#by_version(direction = :asc) ⇒ Object
14 15 16 17 |
# File 'lib/version_record/sorting/simple.rb', line 14 def by_version(direction = :asc) collection = @klass.all direction.to_sym == :asc ? sort_asc(collection) : sort_desc(collection) end |