Sha256: 49eb5d18afb49bf2942023c6f42395fa918b03887d3554b9eeee7023fd78ed4d

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

# HashFlatten

Just one method i sometimes miss on Hash. It recursivelly flattens hash to be just one level deep.

hash = { a: 'a',
         b: { a: 'b' },
         c: { b: { a: 'c' } } }

hash.flatten =>

  { 'a' => 'a',
    'b.a' => 'b',
    'c.b.a' => 'c' }

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'hash_flatten'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install hash_flatten

## Usage

Use as refinement:
```
class MyClass
  using HashFlatten
end
```
now you can call `#flatten` on hashes in `MyClass`.

Here is an excellent blog post on refinements if you didn't use them before: http://interblah.net/why-is-nobody-using-refinements

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hash_flatten-0.1.0 README.md