class Bmg::Ordering

Attributes

attrs[R]

Public Class Methods

new(attrs) click to toggle source
# File lib/bmg/support/ordering.rb, line 4
def initialize(attrs)
  @attrs = attrs
end

Public Instance Methods

comparator() click to toggle source
# File lib/bmg/support/ordering.rb, line 9
def comparator
  ->(t1, t2) {
    attrs.each do |(attr,direction)|
      c = t1[attr] <=> t2[attr]
      return (direction == :desc ? -c : c) unless c==0
    end
    0
  }
end