Sha256: acb26e6ffac690c5075c884bd23019c0c424fbb3d860a80fcbb39711ffb18af1
Contents?: true
Size: 648 Bytes
Versions: 1
Compression:
Stored size: 648 Bytes
Contents
require "hashtring/version" require "core_ext/string" module Hashtring class Constructor attr_accessor :name, :hash def initialize(name, hash={}) @name = name.to_s @hash = hash end def [](*args) hash.send(:[], *args) end def inspect to_s end def method_missing(method_sym, *args, &block) if stringify_keys(hash).has_key? method_sym.to_s stringify_keys(hash).send(:[], method_sym.to_s) else super end end def to_s name.to_s end private def stringify_keys(hash) Hash[hash.map { |k, v| [k.to_s, v] }] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hashtring-0.0.1 | lib/hashtring.rb |