Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hashie_mash_knockoff

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashie_mash_knockoff

  • 0.4.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

HashieMashKnockoff

  • A Hashie::Mash knockoff
  • This is a prototype
  • Built and tested with Ruby 2.2.3

Setup

Add it to your Gemfile or...

gem install hashie_mash_knockoff

Test

bundle exec rspec

Usage

require 'hashie_mash_knockoff'

# access hash keys with method calls
hash     = { a: 'b', c: { d: 'e' }, f: {} }
hashie_mash_knockoff = HashieMashKnockoff.new(hash)
hashie_mash_knockoff.a         # returns 'b'
hashie_mash_knockoff.a = ''    # raises NoMethodError
hashie_mash_knockoff[:a]       # returns 'b'
hashie_mash_knockoff[:a] = ''  # raises NoMethodError
hashie_mash_knockoff.c         # returns instance of HashIsh w/ hash of { d: 'e' }
hashie_mash_knockoff.c.class   # returns HashIsh
hashie_mash_knockoff[:c]       # returns { d: 'e' }
hashie_mash_knockoff[:c].class # returns Hash
hashie_mash_knockoff.c.d       # returns 'e'
hashie_mash_knockoff.f         # returns {}
hashie_mash_knockoff.f.class   # returns Hash
hashie_mash_knockoff[:f]       # returns {}
hashie_mash_knockoff[:f].class # returns Hash

# set default values
hash     = { a: nil, b: { c: false }, d: { e: '>_<' } }
defaults = { a: 123, b: { c: true  }, d: { e: 'ಠ_ಠ' } }
hashie_mash_knockoff = HashieMashKnockoff.new(hash, defaults)
hashie_mash_knockoff.a   # returns 123,  overrides falsey nil
hashie_mash_knockoff.b.c # returns true, overrides falsey false
hashie_mash_knockoff.d.e # returns 'lol', not overriden due to 'lol' being truthy

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 20 Nov 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc