Sha256: 797db00c5cd3951dd4563e86d02511b51ac7c69a6a667fbad37fb506b0371482

Contents?: true

Size: 413 Bytes

Versions: 1

Compression:

Stored size: 413 Bytes

Contents

class ExtendHash < Hash
  def []=(key, value)
    key = key.to_sym if String === key
    super(key, value)
  end

  def [](key)
    key = key.to_sym if String === key
    super(key)
  end

  def method_missing(name, *args)
    if name =~ /=$/
      store(name[0...-1].to_sym, args[0])
    elsif has_key?(name)
      fetch(name)
    else
      raise NoMethodError, "-- :#{name}, #{args.inspect}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tagen-1.0.4 lib/tagen/core/extend_hash.rb