Sha256: 6d3940a672f4f0d208dbbc06b52764bf95970193ad4d3c144989131f635cb890

Contents?: true

Size: 587 Bytes

Versions: 2

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

module Cursed
  module Adapter
    class Array < Base
      def descend_by(attribute)
        relation.sort_by!(&attribute)
        relation.reverse!
      end

      def ascend_by(attribute)
        relation.sort_by!(&attribute)
      end

      def limit(count)
        @relation = relation.take(count)
      end

      def after(attribute, value)
        relation.select! { |x| x.public_send(attribute) > value }
      end

      def before(attribute, value)
        relation.select! { |x| x.public_send(attribute) < value }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cursed-0.2.0 lib/cursed/adapter/array.rb
cursed-0.1.0 lib/cursed/adapter/array.rb