0.0
No commit activity in last 3 years
No release in over 3 years
Query against collections
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
>= 0
>= 0

Runtime

>= 0
 Project Readme

Qenumerable

Allows you to query against collections using Izzy's matches_all?

Usage

Let's get ourselves a collection to use:

class Object; include QEnumerable end

brandon = Person.new('brandon', 23, 'm')
john    = Person.new('john',    42, 'm')
jill    = Person.new('jill',    31, 'f')
alice   = Person.new('alice',   50, 'f')
zeke    = Person.new('zeke',    18, 'm')

people = [brandon, john, jill, alice, zeke]

Select Where

Select all objects where params match:

people.select_where name: /^j/
# => [john, jill]

people.select_where(
  age: [
    (20..35),
    -> a { a.odd? }
  ]
)
# => [brandon]

Reject Where

Reject all objects where params match:

people.reject_where name: /^j/
# => [brandon, alice, zeke]

people.reject_where(
  age: [
    (20..35),
    -> a { a.odd? }
  ]
)
# => [john, jill, alice, zeke]

Find Where

Finds the first object where params match:

people.find_where name: /^j/, gender: 'm'
# => john

Installation

Add this line to your application's Gemfile:

gem 'qenumerable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install qenumerable

Contributing

  1. Fork it ( http://github.com/baweaver/qenumerable/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request