diff options
author | jessib <jessib@leap.se> | 2012-12-20 15:13:26 -0800 |
---|---|---|
committer | jessib <jessib@leap.se> | 2012-12-20 15:13:26 -0800 |
commit | aeb69e4abf69993157f9970fa5503b7f9fd4aab5 (patch) | |
tree | 184282f312a2e5c95bbd4fd8bddb9155c4c0f2ba /help/app/models | |
parent | a920cbfb8c35cc7452b258e2f007469c9bc9b9b1 (diff) |
Define ascending method in CouchRest::Model::Designs::View so we can call the order either way.
Diffstat (limited to 'help/app/models')
-rw-r--r-- | help/app/models/ticket_selection.rb | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/help/app/models/ticket_selection.rb b/help/app/models/ticket_selection.rb index cb20f5b..bebe5fc 100644 --- a/help/app/models/ticket_selection.rb +++ b/help/app/models/ticket_selection.rb @@ -8,12 +8,7 @@ class TicketSelection end def tickets - #TODO: can this be more succinct? - if order - Ticket.send(finder_method).startkey(startkey).endkey(endkey).send(order) - else - Ticket.send(finder_method).startkey(startkey).endkey(endkey) - end + Ticket.send(finder_method).startkey(startkey).endkey(endkey).send(order) end protected @@ -47,7 +42,8 @@ class TicketSelection end def order - 'descending' if @options[:sort_order].end_with? 'desc' + # we have defined the ascending method to return the view itself: + (@options[:sort_order].end_with? 'desc') ? 'descending' : 'ascending' end |