Skip to content

Simple select helpers with standalone or extension APIs

License

Notifications You must be signed in to change notification settings

trunkclub/select_where

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SelectWhere

Simple select helpers with standalone or extension APIs. Specify target values with simple values or Procs.

Install

Add the following line to your Gemfile:

gem 'select_where'
Methods
select_where / detect_where
require 'select_where'

arr = [{ a: 1 }, { a: 2 }]
SelectWhere.select(arr, { a: 2 }) # => [{ a: 2}]
SelectWhere.detect(arr, { a: 2 }) # => { a: 2}
SelectWhere.select(arr, { a: ->(v) { v > 0 } }) # => [{ a: 1 }, { a: 2 }]

require 'select_where/core_ext/array'
arr = [{ a: 1 }, { a: 2 }]
arr.select_where({ a: 2 }) # => [{ a: 2}]
arr.detect_where({ a: 2 }) # => { a: 2}
arr.select_where({ a: ->(v) { v > 0 } }) # => [{ a: 1 }, { a: 2 }]
fetch_map
require 'select_where'

arr = [{ a: 1 }, { a: 2 }, { b: 3 }]
SelectWhere.fetch_map(arr, :a, nil) # => [1, 2, nil]

require 'select_where/core_ext/array'
arr.fetch_map(:a, nil) # => [1, 2, nil]

About

Simple select helpers with standalone or extension APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages