Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Simplify Relation#order
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Jul 28, 2013
1 parent f3396c4 commit a84640a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/rom/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def drop(offset)
end

def order(*attributes)
sorted = relation.project(attributes).header | relation.header
new(relation.sort_by { sorted })
new(relation.sort_by { relation.project(attributes).header })

This comment has been minimized.

Copy link
@dkubb

dkubb Jul 28, 2013

Contributor

Does new(relation.sort_by { attributes }) work?

This comment has been minimized.

Copy link
@solnic

solnic Jul 28, 2013

Author Owner

Nope. Getting error saying duplicate names: [:name]

This comment has been minimized.

Copy link
@dkubb

dkubb Jul 28, 2013

Contributor

@solnic I think that's a bug. in the meantime, does this work for you:

new(relation.sort_by(relation.header.project(attributes)))

It was my intention for the API to become this:

new(relation.sort_by(attributes))
end

def sort_by(*args, &block)
Expand Down

0 comments on commit a84640a

Please sign in to comment.