Sha256: c3ba3fee0610a01269d3d5aeea178b656b631c757932a6e57cfc52be57e674cd

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

# InactiveSupport

A collection of utilities for ruby projects.

## Installation

Add this line to your application's Gemfile:

    gem 'inactive_support'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install inactive_support

## Usage

### Object
#### #identity
returns self

    [1,2,3,3,4,5,5].group_by(&:identity)
    # => [[1], [2], [3,3], [4], [5,5]]

#### #try
send a message to the receiver and if it doesn't respond to the message, return nil

    "".try(:some_method)
    # => nil

#### #ctry
chained try, for methods with no arguments

    "Somestring".ctry(:mb_chars, :downcase, :some_method)
    # => nil

### Hash
#### #delete_blank
Deletes all key/value pairs where the value is an empty string/array/hash or nil.

    { name: nil, age: 19, address: "" }.delete_blank
    # => { age: 19 }

### Enumerable
#### #consecutive_by
groups objects by an attribute that is consecutive

    [1,2,3,5,6,8,9].consecutive_by(&:identity)
    # => [[1,2,3],[5,6],[8,9]]


## Contributing

1. Fork it
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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inactive_support-1.1.0 README.md