https://github.com/maxpleaner/keyword_hash_builder
https://github.com/maxpleaner/keyword_hash_builder
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/maxpleaner/keyword_hash_builder
- Owner: MaxPleaner
- Created: 2017-01-04T07:12:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-08T04:05:02.000Z (over 9 years ago)
- Last Synced: 2024-10-31T02:25:20.011Z (over 1 year ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
_gem skeleton generated with [gemmy](http://github.com/maxpleaner/gemmy)_
This provides a syntax somewhat similar to Javascript's shorthand for constructing hashes.
This code is copied from a stack overflow answer authored by user `akuhn`:
http://stackoverflow.com/a/41456114/2981429
---
Usage:
1. `gem 'keyword_hash_builder'`
2. `require 'keyword_hash_builder'`
3. load patch in one of two ways:
1. globally
KeywordHashBuilder.load_globally
2. refinement
# in a class / module definition
using KeywordHashBuilder.patch
4. Use this syntax:
a = 1
b = 2
c = String
puts `a,b,c`
# => { a: 1, b: 2, c: String }