Socket
Book a DemoInstallSign in
Socket

hash-class

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-class

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Hash-class will extend the Hash object with assign_if. This function reduces the verbosity when conditionaly assigning the value by key (within the basic Hash object).

Example:

# old
a = hash[:some_element] if hash.include?(:some_element)
# new
hash.assign_if(:some_element) {|e| a = e}

Logic

Block {|e| a = e} is yielded when key :some_element in hash is found. e contains the value of key :some_element. NOTE: When the key is not found, the block is not yielded!

Usage

Add gem to your Gemfile

gem 'hash-class', github: 'dblommesteijn/hash-class'

Use as standalone gem

gem install specific_install
gem specific_install https://github.com/dblommesteijn/hash-class

Code snippet

require 'hash-class'
a = 123
hash = {}
hash.assign_if(:some_element) {|e| a = e}

Run Tests

ruby -I test test/unit/test_hash.rb

FAQs

Package last updated on 03 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.