Class: TextRecord::Collection
- Inherits:
-
Array
- Object
- Array
- TextRecord::Collection
- Defined in:
- lib/text_record/collection.rb
Instance Method Summary collapse
Instance Method Details
#order(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/text_record/collection.rb', line 12 def order() attribute = .keys.first order = [attribute] sort do |object1, object2| comp = object1.send(attribute) <=> object2.send(attribute) comp = (order == :asc) ? comp : comp * -1 comp end end |
#where(options = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/text_record/collection.rb', line 3 def where( = {}) select do |object| .keys.inject(true) do |flag, attribute| object.send(attribute).eql?([attribute]) && flag end end end |